Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/getgrav/grav into 1.5
Browse files Browse the repository at this point in the history
  • Loading branch information
mahagr committed Aug 13, 2018
2 parents fde75e1 + 63161e6 commit 5c2f994
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 60 deletions.
34 changes: 34 additions & 0 deletions system/src/Grav/Common/Page/Medium/VideoMedium.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,40 @@ public function autoplay($status = false)
return $this;
}

/**
* Allows to set the playsinline attribute
*
* @param bool $status
* @return $this
*/
public function playsinline($status = false)
{
if($status) {
$this->attributes['playsinline'] = true;
} else {
unset($this->attributes['playsinline']);
}

return $this;
}

/**
* Allows to set the muted attribute
*
* @param bool $status
* @return $this
*/
public function muted($status = false)
{
if($status) {
$this->attributes['muted'] = true;
} else {
unset($this->attributes['muted']);
}

return $this;
}

/**
* Reset medium.
*
Expand Down
72 changes: 13 additions & 59 deletions system/src/Grav/Common/Utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -717,11 +717,11 @@ public static function isPositive($value)
* with reverse proxy setups.
*
* @param string $action
* @param bool $plusOneTick if true, generates the token for the next tick (the next 12 hours)
* @param bool $previousTick if true, generates the token for the previous tick (the previous 12 hours)
*
* @return string the nonce string
*/
private static function generateNonceString($action, $plusOneTick = false)
private static function generateNonceString($action, $previousTick = false)
{
$username = '';
if (isset(Grav::instance()['user'])) {
Expand All @@ -732,29 +732,8 @@ private static function generateNonceString($action, $plusOneTick = false)
$token = session_id();
$i = self::nonceTick();

if ($plusOneTick) {
$i++;
}

return ($i . '|' . $action . '|' . $username . '|' . $token . '|' . Grav::instance()['config']->get('security.salt'));
}

//Added in version 1.0.8 to ensure that existing nonces are not broken.
private static function generateNonceStringOldStyle($action, $plusOneTick = false)
{
if (isset(Grav::instance()['user'])) {
$user = Grav::instance()['user'];
$username = $user->username;
if (isset($_SERVER['REMOTE_ADDR'])) {
$username .= $_SERVER['REMOTE_ADDR'];
}
} else {
$username = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '';
}
$token = session_id();
$i = self::nonceTick();
if ($plusOneTick) {
$i++;
if ($previousTick) {
$i--;
}

return ($i . '|' . $action . '|' . $username . '|' . $token . '|' . Grav::instance()['config']->get('security.salt'));
Expand All @@ -780,33 +759,20 @@ private static function nonceTick()
* action is the same for 12 hours.
*
* @param string $action the action the nonce is tied to (e.g. save-user-admin or move-page-homepage)
* @param bool $plusOneTick if true, generates the token for the next tick (the next 12 hours)
* @param bool $previousTick if true, generates the token for the previous tick (the previous 12 hours)
*
* @return string the nonce
*/
public static function getNonce($action, $plusOneTick = false)
public static function getNonce($action, $previousTick = false)
{
// Don't regenerate this again if not needed
if (isset(static::$nonces[$action])) {
return static::$nonces[$action];
if (isset(static::$nonces[$action][$previousTick])) {
return static::$nonces[$action][$previousTick];
}
$nonce = md5(self::generateNonceString($action, $plusOneTick));
static::$nonces[$action] = $nonce;
$nonce = md5(self::generateNonceString($action, $previousTick));
static::$nonces[$action][$previousTick] = $nonce;

return static::$nonces[$action];
}

//Added in version 1.0.8 to ensure that existing nonces are not broken.
public static function getNonceOldStyle($action, $plusOneTick = false)
{
// Don't regenerate this again if not needed
if (isset(static::$nonces[$action])) {
return static::$nonces[$action];
}
$nonce = md5(self::generateNonceStringOldStyle($action, $plusOneTick));
static::$nonces[$action] = $nonce;

return static::$nonces[$action];
return static::$nonces[$action][$previousTick];
}

/**
Expand All @@ -830,20 +796,8 @@ public static function verifyNonce($nonce, $action)
}

//Nonce generated 12-24 hours ago
$plusOneTick = true;
if ($nonce === self::getNonce($action, $plusOneTick)) {
return true;
}

//Added in version 1.0.8 to ensure that existing nonces are not broken.
//Nonce generated 0-12 hours ago
if ($nonce === self::getNonceOldStyle($action)) {
return true;
}

//Nonce generated 12-24 hours ago
$plusOneTick = true;
if ($nonce === self::getNonceOldStyle($action, $plusOneTick)) {
$previousTick = true;
if ($nonce === self::getNonce($action, $previousTick)) {
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion user/pages/02.typography/default.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ _Italic_ `_Italic_`

Text<sup>Superscripted</sup> `<sup>`

Text<sub>Subscxripted</sub> `<sub>`
Text<sub>Subscripted</sub> `<sub>`

<u>Underlined</u> `<u>`

Expand Down

0 comments on commit 5c2f994

Please sign in to comment.