php-diff: Fix undefined offset in Array Renderer

See https://github.com/chrisboulton/php-diff/pull/51
This commit is contained in:
Markus Frosch 2018-05-09 08:55:44 +02:00 committed by Thomas Gelf
parent 09f4a1c94f
commit f19a41d11a
2 changed files with 29 additions and 7 deletions

View File

@ -3,17 +3,34 @@
set -ex
# version based on current master 3cb3f7ce6bb8b910f5a41ea1887b1faceba6a7d7
# plus https://github.com/chrisboulton/php-diff/pull/50
# plus pull requests:
# - https://github.com/chrisboulton/php-diff/pull/50
# - https://github.com/chrisboulton/php-diff/pull/51
git clone https://github.com/chrisboulton/php-diff.git
cd php-diff
git fetch origin pull/50/head:pr
git checkout a9f124f81a9436138879e56157c6cced52a6d95b
git show -s
# master
git checkout 3cb3f7ce6bb8b910f5a41ea1887b1faceba6a7d7
# PR #50
git fetch origin pull/50/head:pr-50
git cherry-pick a9f124f81a9436138879e56157c6cced52a6d95b
# PR #51
git fetch origin pull/51/head:pr-51
git cherry-pick cb0d0781bcc6b0ae39d73715c659a6d2717d28e1
git log -4
rm -rf .git
rm -rf .gitignore
rm -rf composer.json
rm -rf example tests phpunit.xml
cd ..
echo "Now you can run:"
echo " rsync -av php-diff/ ./ --delete --exclude=SOURCE --exclude=php-diff/"
echo "and:"
echo " rm -rf php-diff/"

View File

@ -190,9 +190,14 @@ class Diff_Renderer_Html_Array extends Diff_Renderer_Abstract
*/
private function fixSpaces(array $matches)
{
$spaces = $matches[1];
$count = strlen($spaces);
if($count == 0) {
$count = 0;
if (count($matches) > 1) {
$spaces = $matches[1];
$count = strlen($spaces);
}
if ($count == 0) {
return '';
}