Skip to content
This repository has been archived by the owner on Apr 1, 2024. It is now read-only.

Commit

Permalink
Update fastpath to catch opening tags.
Browse files Browse the repository at this point in the history
Summary:
If you have something like:

  $foo = <div>Her's</div>;

The fastpath won't pick up the XHP because it thinks it's inside of a string, and it only looks for closing tags, not opening tags. I added an expression to detect opening tags as well, which in practice won't have many false positives.

Test Plan:
New unit test. Also ran xhpize on FB sources and no new fastpath false positives were introduced.

Reviewed By: epriestley
  • Loading branch information
Marcel Laverdet committed Dec 2, 2010
1 parent 8cf200e commit dafff2c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
9 changes: 9 additions & 0 deletions tests/apos-fastpath.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
--TEST--
Apostrophe Fastpath
--FILE--
<?php
$foo = xhp_preprocess_code('<?php
$foo = <div>Her\'s</div>;foo(\'\');');
echo isset($foo['new_code']);
--EXPECT--
1
1 change: 1 addition & 0 deletions xhp/fastpath.re
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ bool xhp_fastpath(const char* yy, const size_t len, const xhp_flags_t &flags) {
<PHP> '::' { continue; }
<PHP> '</'|
'/>'|
'<'[a-zA-Z0-9:_\-]+'>'|
':'[a-zA-Z0-9]|
')'WHITESPACE*'['|
'&#' {
Expand Down

0 comments on commit dafff2c

Please sign in to comment.