Compare commits

...

15 Commits
1.4.4 ... 1.4.5

Author SHA1 Message Date
Andy Miller
03a0c42795 Merge branch 'release/1.4.5' 2018-05-15 12:55:39 -06:00
Andy Miller
1426a7ec95 prepare for release 2018-05-15 12:55:27 -06:00
Andy Miller
2a759eed74 updated changelog 2018-05-15 11:46:54 -06:00
Andy Miller
8980b78220 Revert "Add MIME type to video <source> tag (#1992)"
This reverts commit e60fd82400.
2018-05-15 11:45:36 -06:00
Andy Miller
12b0a839e7 Merge branch 'develop' of github.com:getgrav/grav into develop 2018-05-15 11:43:42 -06:00
Andy Miller
b4d570fd21 updated changelog 2018-05-15 11:43:37 -06:00
Christian Weiske
e60fd82400 Add MIME type to video <source> tag (#1992) 2018-05-15 11:39:50 -06:00
Davide Liessi
a1abcfd067 Move fix for #1114 to Truncator::truncateLetters (#2004)
* Move fix for #1114 to Truncator::truncateLetters

The original fix provided by #1125 in Utils::truncateHtml compared the
summary size with the full HTML string length.
Thus, the string was still being truncated (and the HTML rewritten) even
when only the HTML string length, and not the text length, exceeded the
summary size.

* Add fix for #1114 also to Truncator::truncateWords
2018-05-15 11:38:48 -06:00
Christian Weiske
7f90ad8474 Do not crash when generating URLs with arrays as parameters (#2018)
When using a default image derivatives (#1979) setting like

  images:
    defaults:
      derivatives: [300,600]

then Grav crashes when a video gets embedded.
The following error occurs:

  rawurlencode() expects parameter 1 to be string, array given
  system/src/Grav/Common/Page/Medium/Medium.php:521

This patch encodes array URL parameters correctly.
2018-05-15 11:37:18 -06:00
Andy Miller
e1d52181a3 updated changelog 2018-05-15 11:36:20 -06:00
Matias Griese
d4494cb502 Fixed users getting logged out after Grav upgrade 2018-05-15 16:26:11 +03:00
Andy Miller
2f17b3fa7d Revert "Add special handling for User authenticated and authorized properties"
This reverts commit 8e0e3e8718.
2018-05-14 18:25:19 -06:00
Matias Griese
afe72d0783 Merge remote-tracking branch 'origin/develop' into develop 2018-05-14 21:24:03 +03:00
Matias Griese
8e0e3e8718 Add special handling for User authenticated and authorized properties 2018-05-14 21:23:56 +03:00
Andy Miller
30ff986603 Merge tag '1.4.4' into develop
Releaase v1.4.4
2018-05-11 16:07:38 -06:00
7 changed files with 68 additions and 13 deletions

View File

@@ -1,3 +1,11 @@
# v1.4.5
## 05/15/2018
1. [](#bugfix)
* Fixed an issue with some users getting **2FA** prompt after upgrade [admin#1442](https://github.com/getgrav/grav-plugin-admin/issues/1442)
* Do not crash when generating URLs with arrays as parameters [#2018](https://github.com/getgrav/grav/pull/2018)
* Utils::truncateHTML removes whitespace when generating summaries [#2004](https://github.com/getgrav/grav/pull/2004)
# v1.4.4
## 05/11/2018

View File

@@ -8,7 +8,7 @@
// Some standard defines
define('GRAV', true);
define('GRAV_VERSION', '1.4.4');
define('GRAV_VERSION', '1.4.5');
define('GRAV_TESTING', false);
define('DS', '/');

View File

@@ -47,6 +47,7 @@ class Truncator {
// Iterate over words.
$words = new DOMWordsIterator($body);
$truncated = false;
foreach ($words as $word) {
// If we have exceeded the limit, we delete the remainder of the content.
@@ -70,12 +71,19 @@ class Truncator {
self::insertEllipsis($curNode, $ellipsis);
}
$truncated = true;
break;
}
}
return self::innerHTML($body);
// Return original HTML if not truncated.
if ($truncated) {
return self::innerHTML($body);
} else {
return $html;
}
}
/**
@@ -98,6 +106,7 @@ class Truncator {
// Iterate over letters.
$letters = new DOMLettersIterator($body);
$truncated = false;
foreach ($letters as $letter) {
// If we have exceeded the limit, we want to delete the remainder of this document.
@@ -111,11 +120,18 @@ class Truncator {
self::insertEllipsis($currentText[0], $ellipsis);
}
$truncated = true;
break;
}
}
return self::innerHTML($body);
// Return original HTML if not truncated.
if ($truncated) {
return self::innerHTML($body);
} else {
return $html;
}
}
/**

View File

@@ -536,7 +536,12 @@ class Medium extends Data implements RenderableInterface
{
$qs = $method;
if (count($args) > 1 || (count($args) == 1 && !empty($args[0]))) {
$qs .= '=' . implode(',', array_map(function ($a) { return rawurlencode($a); }, $args));
$qs .= '=' . implode(',', array_map(function ($a) {
if (is_array($a)) {
$a = '[' . implode(',', $a) . ']';
}
return rawurlencode($a);
}, $args));
}
if (!empty($qs)) {

View File

@@ -95,11 +95,41 @@ class User extends Data
public static function remove($username)
{
$file_path = Grav::instance()['locator']->findResource('account://' . $username . YAML_EXT);
if ($file_path && unlink($file_path)) {
return true;
return $file_path && unlink($file_path);
}
/**
* @param string $offset
* @return bool
*/
public function offsetExists($offset)
{
$value = parent::offsetExists($offset);
// Handle special case where user was logged in before 'authorized' was added to the user object.
if (false === $value && $offset === 'authorized') {
$value = $this->offsetExists('authenticated');
}
return false;
return $value;
}
/**
* @param string $offset
* @return mixed
*/
public function offsetGet($offset)
{
$value = parent::offsetGet($offset);
// Handle special case where user was logged in before 'authorized' was added to the user object.
if (null === $value && $offset === 'authorized') {
$value = $this->offsetGet('authenticated');
$this->offsetSet($offset, $value);
}
return $value;
}
/**

View File

@@ -296,10 +296,6 @@ abstract class Utils
*/
public static function truncateHtml($text, $length = 100, $ellipsis = '...')
{
if (mb_strlen($text) <= $length) {
return $text;
}
return Truncator::truncateLetters($text, $length, $ellipsis);
}

View File

@@ -127,7 +127,7 @@ class UtilsTest extends \Codeception\TestCase\Test
$this->assertEquals('<p>This...</p>', Utils::truncateHtml('<p>This is a string to truncate</p>', 4));
$this->assertEquals('<p>This is a...</p>', Utils::truncateHtml('<p>This is a string to truncate</p>', 10));
$this->assertEquals('<p>This is a string to truncate</p>', Utils::truncateHtml('<p>This is a string to truncate</p>', 100));
$this->assertEquals('<input type="file" id="file" multiple>', Utils::truncateHtml('<input type="file" id="file" multiple />', 6));
$this->assertEquals('<input type="file" id="file" multiple />', Utils::truncateHtml('<input type="file" id="file" multiple />', 6));
$this->assertEquals('<ol><li>item 1 <i>so...</i></li></ol>', Utils::truncateHtml('<ol><li>item 1 <i>something</i></li><li>item 2 <strong>bold</strong></li></ol>', 10));
$this->assertEquals("<p>This is a string.</p>\n<p>It splits two lines.</p>", Utils::truncateHtml("<p>This is a string.</p>\n<p>It splits two lines.</p>", 100));
}
@@ -138,7 +138,7 @@ class UtilsTest extends \Codeception\TestCase\Test
$this->assertEquals('<p>This is...</p>', Utils::safeTruncateHtml('<p>This is a string to truncate</p>', 2));
$this->assertEquals('<p>This is a string to...</p>', Utils::safeTruncateHtml('<p>This is a string to truncate</p>', 5));
$this->assertEquals('<p>This is a string to truncate</p>', Utils::safeTruncateHtml('<p>This is a string to truncate</p>', 20));
$this->assertEquals('<input type="file" id="file" multiple>', Utils::safeTruncateHtml('<input type="file" id="file" multiple />', 6));
$this->assertEquals('<input type="file" id="file" multiple />', Utils::safeTruncateHtml('<input type="file" id="file" multiple />', 6));
$this->assertEquals('<ol><li>item 1 <i>something</i></li><li>item 2...</li></ol>', Utils::safeTruncateHtml('<ol><li>item 1 <i>something</i></li><li>item 2 <strong>bold</strong></li></ol>', 5));
}