]> granicus.if.org Git - php/commitdiff
Fixed bug #21453 (improper handling of non-terminated <).
authorIlia Alshanetsky <iliaa@php.net>
Mon, 6 Jan 2003 22:13:03 +0000 (22:13 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Mon, 6 Jan 2003 22:13:03 +0000 (22:13 +0000)
ext/standard/string.c
ext/standard/tests/strings/bug21453.phpt [new file with mode: 0644]

index ba361ff50978d0b272f1578a622d02ca3740477b..8490abf62104964e7ce465cd5927abd261635e8e 100644 (file)
@@ -3413,6 +3413,9 @@ PHPAPI void php_strip_tags(char *rbuf, int len, int *stateptr, char *allow, int
        while (i < len) {
                switch (c) {
                        case '<':
+                               if (isspace(*(p + 1))) {
+                                       goto reg_char;
+                               }
                                if (state == 0) {
                                        lc = '<';
                                        state = 1;
@@ -3552,6 +3555,7 @@ PHPAPI void php_strip_tags(char *rbuf, int len, int *stateptr, char *allow, int
 
                                /* fall-through */
                        default:
+reg_char:
                                if (state == 0) {
                                        *(rp++) = c;
                                } else if (allow && state == 1) {
diff --git a/ext/standard/tests/strings/bug21453.phpt b/ext/standard/tests/strings/bug21453.phpt
new file mode 100644 (file)
index 0000000..40d89dd
--- /dev/null
@@ -0,0 +1,18 @@
+--TEST--
+Bug #21453 (handling of non-encoded <)
+--FILE--
+<?php
+$test = "
+<table>
+       <tr><td>first cell before < first cell after</td></tr>
+       <tr><td>second cell before < second cell after</td></tr>
+</table>";
+
+       var_dump(strip_tags($test));
+?>
+--EXPECT--
+string(80) "
+
+       first cell before < first cell after
+       second cell before < second cell after
+"