-
Notifications
You must be signed in to change notification settings - Fork 7.9k
No escaping in zend_dump_const
output
#10576
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I'm not sure if this output is really made to be machine readable. Either way, adjusting seems sensible. I don't think there's an existing function that does this. |
@iluuu1994 hmmm... what about Lines 3492 to 3494 in 2ec0134
It is used internally by Line 516 in 2ec0134
|
@SerafimArts You could use that, although it requires an allocation per string. |
Description
The following code:
After some optimization steps, it outputs the following opcodes:
Please pay attention to instruction 0027.
This expression cannot be correctly recognized during any automated analysis of the opcode dump. Even if I take the first and last occurrences of
string("
and")
, then such instructions can disrupt the work of parser:I understand that from the point of view of grammar, this is impossible in principle, but similar cases may arise.
The problem is here: https://github.com/php/php-src/blob/PHP-8.2/Zend/Optimizer/zend_dump.c#L69
I suggest adding character
\\
,"
(and perhaps\n
) escaping so that the output of opcodes can be parsed automatically.However, before sending a PR, I would like to ask if there is already a ready-made function that escapes the specified sequences, instead of
Z_STRVAL_P
.The text was updated successfully, but these errors were encountered: