Page MenuHomePhabricator

XHPAST doesn't handle complex embedded variables in strings using the same quoting style
Open, Needs TriagePublic


Hello! Long time no see, missed the introduction of badges and everything.

Ran into an issue generating PHP symbols for a codebase:

[2016-06-02 11:44:01] EXCEPTION: (XHPASTSyntaxErrorException) XHPAST Parse Error: syntax error, unexpected T_STRING, expecting ')' on line 172 at [<phutil>/src/parser/xhpast/api/XHPASTTree.php:55]
arcanist(head=master, ref.master=c58f1b9a2507), phabricator(head=master, ref.master=8b7f8cb61f47), phutil(head=master, ref.master=0709cd5cfc26)
#0 XHPASTTree::newFromDataAndResolvedExecFuture(string, array) called at [<phabricator>/scripts/symbols/generate_php_symbols.php:40]

The line in question is:

syslog(LOG_INFO, "Bypassing auth proxy from '{$_SERVER["REMOTE_ADDR"]}' is not allowed. Access Denied");

After poking at it for a few moments, this is parsed correctly:

syslog(LOG_INFO, "Bypassing auth proxy from '{$_SERVER['REMOTE_ADDR']}' is not allowed. Access Denied");

At first I thought it might be breaking out of the string completely and just hitting PHP's amazing treat-unknown-constants-as-strings behaviour, but it doesn't trigger any notices (and removing the quotes does).

I'll probably try and replace this usage in our codebase, but it's apparently valid PHP syntax.

This is covered by T8049, but this errors rather than just being degraded parsing.