Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ PHP NEWS
. Fixed AST export of by-reference property hooks. (Jorg Sowa)
. Fixed AST export of property hook parameter lists and attributes.
(Jorg Sowa)
. Fixed AST export treating 0x7f as a valid name character. (Jorg Sowa)

- Curl:
. Fixed curl_reset() retaining CURLOPT_PRIVATE after reset. (lacatoire)
Expand Down
57 changes: 57 additions & 0 deletions Zend/tests/ast/ast_export_del_in_names.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
--TEST--
AST export of names containing 0x7f
--EXTENSIONS--
zend_test
--FILE--
<?php

$code = <<<'PHP'
<?php
C::{"\x7f"};
C::{"a\x7f"};
C::{"\x7fa"};
$o::{"\x7f"};
C::{"\x7f"}();
$o::{"\x7f"}();
${"\x7f"};
${"a\x7f"};
$o->{"\x7f"};
$o?->{"\x7f"};
$o->{"\x7f"}();
$o?->{"\x7f"}();
C::${"\x7f"};
"x{${"\x7f"}}y";
"x{$o->{"\x7f"}}y";
"{$a}\x7f";
C::{"\x80"};
${"\xff"};
$o->{"a\x80"};
"{$a}\x80";
PHP;

$export = zend_test_compile_to_ast($code);
echo addcslashes($export, "\x7f..\xff");
eval("return;\n$export");

?>
--EXPECT--
C::{'\177'};
C::{'a\177'};
C::{'\177a'};
$o::{'\177'};
C::{'\177'}();
$o::{'\177'}();
${'\177'};
${'a\177'};
$o->{'\177'};
$o?->{'\177'};
$o->{'\177'}();
$o?->{'\177'}();
C::${'\177'};
"x{${'\177'}}y";
"x{$o->{'\177'}}y";
"{$a}\177";
C::\200;
$\377;
$o->a\200;
"{$a}\200";
4 changes: 2 additions & 2 deletions Zend/zend_ast.c
Original file line number Diff line number Diff line change
Expand Up @@ -1875,14 +1875,14 @@ static ZEND_COLD bool zend_ast_valid_var_name(const char *s, size_t len)
return false;
}
c = (unsigned char)s[0];
if (c != '_' && c < 127 &&
if (c != '_' && c < 128 &&
(c < 'A' || c > 'Z') &&
(c < 'a' || c > 'z')) {
return false;
}
for (i = 1; i < len; i++) {
c = (unsigned char)s[i];
if (c != '_' && c < 127 &&
if (c != '_' && c < 128 &&
(c < '0' || c > '9') &&
(c < 'A' || c > 'Z') &&
(c < 'a' || c > 'z')) {
Expand Down
Loading