MDL-60239 libraries: patch Markdown for PHP7.2

This commit is contained in:
Marina Glancy 2017-10-02 15:15:36 +08:00 committed by Andrew Nicols
parent 0b55f881f1
commit 2a1275479c
3 changed files with 12 additions and 3 deletions

View File

@ -1870,9 +1870,9 @@ class Markdown implements MarkdownInterface {
return;
}
$this->utf8_strlen = create_function('$text', 'return preg_match_all(
"/[\\\\x00-\\\\xBF]|[\\\\xC0-\\\\xFF][\\\\x80-\\\\xBF]*/",
$text, $m);');
$this->utf8_strlen = function($text) {
return preg_match_all('/[\x00-\xBF]|[\xC0-\xFF][\x80-\xBF]*/', $text, $m);
};
}
/**

View File

@ -5,6 +5,9 @@ Procedure:
* copy the classes and readme file to lib/markdown/* , Note .inc files need not be copied.
* update function markdown_to_html() in weblib.php if necessary,
note that we require the php files manually for performance reasons
* pull commits https://github.com/michelf/php-markdown/commit/0c1337a4d483b1e0b66bfdc3ffa644eafd40aa27
and https://github.com/michelf/php-markdown/commit/251ffcce7582d4b26936679e340abca973d55220
if they are not included in the next release (or remove this step)
* run phpunit tests
Petr Skoda

View File

@ -63,4 +63,10 @@ class core_markdown_testcase extends basic_testcase {
$result = "<p>some <a href=\"http://example.com/\">example link</a></p>\n";
$this->assertSame($result, markdown_to_html($text));
}
public function test_tabs() {
$text = "a\tbb\tccc\tя\tюэ\t\tabcd\tabcde\tabcdef";
$result = "<p>a bb ccc я юэ 水 abcd abcde abcdef</p>\n";
$this->assertSame($result, markdown_to_html($text));
}
}