Skip to content

Instantly share code, notes, and snippets.

@ngyuki
Last active August 29, 2015 14:04
Show Gist options
  • Save ngyuki/bb902123634383c78c6a to your computer and use it in GitHub Desktop.
Save ngyuki/bb902123634383c78c6a to your computer and use it in GitHub Desktop.
php-zend-multibyte-bug
<?php
declare(encoding='UTF-8');
/* あああ */
?>
$ out/php -v
PHP 5.7.0-dev (cli) (built: Jul 23 2014 16:43:49) (DEBUG)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.7.0-dev, Copyright (c) 1998-2014 Zend Technologies
$ out/php -d zend.multibyte=1 -d mbstring.internal_encoding=EUC_JP dev.php | od -c
0000000 \0 \0 \0
0000003
diff --git a/Zend/zend_language_scanner.c b/Zend/zend_language_scanner.c
index ae41cde..34c88a8 100644
--- a/Zend/zend_language_scanner.c
+++ b/Zend/zend_language_scanner.c
@@ -853,7 +853,7 @@ ZEND_API void zend_multibyte_yyinput_again(zend_encoding_filter old_input_filter
SCNG(yy_cursor) = new_yy_start + (SCNG(yy_cursor) - SCNG(yy_start));
SCNG(yy_marker) = new_yy_start + (SCNG(yy_marker) - SCNG(yy_start));
SCNG(yy_text) = new_yy_start + (SCNG(yy_text) - SCNG(yy_start));
- SCNG(yy_limit) = new_yy_start + (SCNG(yy_limit) - SCNG(yy_start));
+ SCNG(yy_limit) = new_yy_start + (SCNG(yy_limit) - SCNG(yy_start)) + length - SCNG(script_org_size);
SCNG(yy_start) = new_yy_start;
}
diff --git a/Zend/zend_language_scanner.l b/Zend/zend_language_scanner.l
index 4f50658..89c055f 100644
--- a/Zend/zend_language_scanner.l
+++ b/Zend/zend_language_scanner.l
@@ -851,7 +851,7 @@ ZEND_API void zend_multibyte_yyinput_again(zend_encoding_filter old_input_filter
SCNG(yy_cursor) = new_yy_start + (SCNG(yy_cursor) - SCNG(yy_start));
SCNG(yy_marker) = new_yy_start + (SCNG(yy_marker) - SCNG(yy_start));
SCNG(yy_text) = new_yy_start + (SCNG(yy_text) - SCNG(yy_start));
- SCNG(yy_limit) = new_yy_start + (SCNG(yy_limit) - SCNG(yy_start));
+ SCNG(yy_limit) = new_yy_start + (SCNG(yy_limit) - SCNG(yy_start)) + length - SCNG(script_org_size);
SCNG(yy_start) = new_yy_start;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment