From fe2705b4c6e8ecd42d2ac6ec04657a44b0aba916 Mon Sep 17 00:00:00 2001 From: Artur Iwicki Date: Jul 29 2020 14:25:43 +0000 Subject: Backport a bugfix required by dokuwiki --- diff --git a/php-geshi-1.0.9.0-fix_php72_deprecation_warning.patch b/php-geshi-1.0.9.0-fix_php72_deprecation_warning.patch deleted file mode 100644 index 8f971c6..0000000 --- a/php-geshi-1.0.9.0-fix_php72_deprecation_warning.patch +++ /dev/null @@ -1,48 +0,0 @@ -From ed9f49a7c7a195f6ed2bc864f5ce03b990b5867d Mon Sep 17 00:00:00 2001 -From: suve -Date: Mon, 11 Dec 2017 19:06:07 +0100 -Subject: [PATCH] Remove usage of create_function() - use a proper anonymous - function instead - -Resolves: https://github.com/GeSHi/geshi-1.0/issues/98 ---- - docs/geshi-doc.html | 5 +++-- - src/geshi.php | 4 +++- - 2 files changed, 6 insertions(+), 3 deletions(-) - -diff --git a/docs/geshi-doc.html b/docs/geshi-doc.html -index d22d4b92..90c8dd75 100644 ---- a/docs/geshi-doc.html -+++ b/docs/geshi-doc.html -@@ -3555,7 +3555,8 @@

4.3.5 Styles for your Language File

-
  • ‘REGEXPS’: This is an array with a style for each matching regex. Also, since 1.0.7.21, you can specify the - name of a function to be called, that will be given the text matched by the regex, each time a match is found. --Note that my testing found that create_function would not work with this due to a PHP bug, so you have to -+Note that my testing found that create_function would not work with this due to a PHP bug -+(not to mention that create_function is deprecated as of PHP 7.2.0), so you have to - put the function definition at the top of the language file. Be sure to prefix the function name - with geshi_[languagename]_ as to not conflict with other functions!
  • -
  • ‘SCRIPT’: For languages that use script delimiters, this is where you can style each block of script. For -@@ -4074,4 +4075,4 @@

    5 Method/Constant Reference

    +Date: Wed, 29 Apr 2020 20:34:10 +0200 +Subject: [PATCH] fix: SF Bug 190: highlight_lines_extra eats end-of-line + +This applies the proposed fix from https://sourceforge.net/p/geshi/bugs/190/ + +Because of the lack of comprehensive tests, it's unclear if this has any +side effects, but it does fix the reported problem. + +A test case for this bug in particular has been added. +--- +Removed the changes to phpunit.xml from the original patch, +since these caused the tests to fail in Fedora. + - Artur Iwicki + + src/geshi.php | 2 +- + tests/NewlineTest.php | 56 +++++++++++++++++++++++++++++++++++++++++++ + 3 files changed, 59 insertions(+), 2 deletions(-) + create mode 100644 tests/NewlineTest.php + +diff --git a/src/geshi.php b/src/geshi.php +index cf5e1632..8c3f0a31 100644 +--- a/src/geshi.php ++++ b/src/geshi.php +@@ -4045,7 +4045,7 @@ protected function finalise(&$parsed_code) { + $parsed_code .= str_repeat('', $close); + $close = 0; + } +- elseif ($i + 1 < $n) { ++ if ($i + 1 < $n) { + $parsed_code .= "\n"; + } + unset($code[$i]); +diff --git a/tests/NewlineTest.php b/tests/NewlineTest.php +new file mode 100644 +index 00000000..593168b8 +--- /dev/null ++++ b/tests/NewlineTest.php +@@ -0,0 +1,56 @@ ++highlight_lines_extra(2); ++ $output = $geshi->parse_code(); ++ $output_lines = count(explode("\n", $output)); ++ ++ $this->assertEquals($input_lines, $output_lines, "number of line mismatch between input and output"); ++ } ++ ++ /** ++ * Highlighting a line ++ * ++ * checks for SF bug 190 ++ * ++ * @link https://sourceforge.net/p/geshi/bugs/190/ ++ */ ++ public function testHighlight() ++ { ++ $input = <<< END ++void main () { ++ printf ("Hello World"); ++ exit 0; ++} ++END; ++ $input_lines = count(explode("\n", $input)); ++ ++ $geshi = new GeSHi($input, 'c'); ++ $geshi->highlight_lines_extra(2); ++ $output = $geshi->parse_code(); ++ $output_lines = count(explode("\n", $output)); ++ ++ $this->assertEquals($input_lines, $output_lines, "number of line mismatch between input and output"); ++ } ++} diff --git a/php-geshi.spec b/php-geshi.spec index b8483c2..e2428ec 100644 --- a/php-geshi.spec +++ b/php-geshi.spec @@ -1,12 +1,17 @@ Name: php-geshi Version: 1.0.9.1 -Release: 4%{?dist} +Release: 5%{?dist} Summary: Generic syntax highlighter License: GPLv2+ URL: https://github.com/GeSHi/geshi-1.0 Source0: %{url}/archive/v%{version}/GeSHi-%{version}.tar.gz +# Fixes the library removing newlines under certain conditions. +# Backported for dokuwiki, which relies on this fix. +# See: https://github.com/GeSHi/geshi-1.0/pull/134 +Patch0: %{name}-1.0.9.1--PR134.patch + BuildArch: noarch # from composer.json "require-dev": { @@ -35,6 +40,7 @@ with the following goals: %prep %setup -q -n geshi-1.0-%{version} +%patch0 -p1 find docs -type f -exec chmod a-x {} ';' find . -type f -name "*.php" -exec chmod a-x {} ';' @@ -66,6 +72,9 @@ cp -a geshi geshi.php %{buildroot}%{_datadir}/php/ %changelog +* Wed Jul 29 2020 Artur Iwicki - 1.0.9.1-5 +- Backport a bugfix required by dokuwiki + * Tue Jul 28 2020 Fedora Release Engineering - 1.0.9.1-4 - Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild