Permalink
Browse files

Update fastpath to catch opening tags.

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...
1 parent 8cf200e commit dafff2cc1844d1138c3388509c9560b87167a3bb @laverdet laverdet committed Dec 2, 2010
Showing with 10 additions and 0 deletions.
  1. +9 −0 tests/apos-fastpath.phpt
  2. +1 −0 xhp/fastpath.re
View
@@ -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
View
@@ -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*'['|
'&#' {

0 comments on commit dafff2c

Please sign in to comment.