]> granicus.if.org Git - php/commitdiff
Fixed Bug #26703 (Certain characters inside strings incorrectly treated as
authorIlia Alshanetsky <iliaa@php.net>
Thu, 25 Dec 2003 18:57:26 +0000 (18:57 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Thu, 25 Dec 2003 18:57:26 +0000 (18:57 +0000)
keywords). Original patch by vrana@php.net.

Zend/zend_highlight.c
tests/strings/bug26703.phpt [new file with mode: 0644]

index fbcd63c61892614ce7c305468f02365834b8a9fd..fd9d2dd4114f36495486839c1d82dc53ab48bce5 100644 (file)
@@ -137,14 +137,12 @@ ZEND_API void zend_highlight(zend_syntax_highlighter_ini *syntax_highlighter_ini
                                continue;
                                break;
                        default:
-                               if (token.type==0) {
+                               if (in_string) {
+                                       next_color = syntax_highlighter_ini->highlight_string;
+                               } else if (token.type == 0) {
                                        next_color = syntax_highlighter_ini->highlight_keyword;
                                } else {
-                                       if (in_string) {
-                                               next_color = syntax_highlighter_ini->highlight_string;
-                                       } else {
-                                               next_color = syntax_highlighter_ini->highlight_default;
-                                       }
+                                       next_color = syntax_highlighter_ini->highlight_default;
                                }
                                break;
                }
diff --git a/tests/strings/bug26703.phpt b/tests/strings/bug26703.phpt
new file mode 100644 (file)
index 0000000..c86e175
--- /dev/null
@@ -0,0 +1,18 @@
+--TEST--
+Bug #26703 (Certain characters inside strings incorrectly treated as keywords)
+--INI--
+highlight.string=#DD0000
+highlight.comment=#FF9900
+highlight.keyword=#007700
+highlight.bg=#FFFFFF
+highlight.default=#0000BB
+highlight.html=#000000
+--FILE--
+<?php
+       highlight_string('<?php echo "foo[] $a \n"; ?>');
+?>
+--EXPECT--
+<code><font color="#000000">
+<font color="#0000BB">&lt;?php </font><font color="#007700">echo </font><font color="#DD0000">"foo[] $a \n"</font><font color="#007700">; </font><font color="#0000BB">?&gt;</font>
+</font>
+</code>