]> granicus.if.org Git - php/commitdiff
- Fixed bug #53319 (strip_tags() may strip '<br />' incorrectly)
authorFelipe Pena <felipe@php.net>
Tue, 16 Nov 2010 22:16:44 +0000 (22:16 +0000)
committerFelipe Pena <felipe@php.net>
Tue, 16 Nov 2010 22:16:44 +0000 (22:16 +0000)
ext/standard/string.c
ext/standard/tests/strings/bug53319.phpt [new file with mode: 0644]

index abd33d6ee8218b501f282122bfba841578ec8766..e39b0cb6ece5c3a1a636c7d1b36941d211bb491c 100644 (file)
@@ -4210,9 +4210,8 @@ int php_tag_find(char *tag, int len, char *set) {
                                if (!isspace((int)c)) {
                                        if (state == 0) {
                                                state=1;
-                                               if (c != '/')
-                                                       *(n++) = c;
-                                       } else {
+                                       }
+                                       if (c != '/') {
                                                *(n++) = c;
                                        }
                                } else {
diff --git a/ext/standard/tests/strings/bug53319.phpt b/ext/standard/tests/strings/bug53319.phpt
new file mode 100644 (file)
index 0000000..0bcc06d
--- /dev/null
@@ -0,0 +1,17 @@
+--TEST--
+Bug #53319 (Strip_tags() may strip '<br />' incorrectly)
+--FILE--
+<?php
+
+$str = '<br /><br  />USD<input type="text"/><br/>CDN<br><input type="text" />';
+var_dump(strip_tags($str, '<input>'));
+var_dump(strip_tags($str, '<br><input>') === $str);
+var_dump(strip_tags($str));
+var_dump(strip_tags('<a/b>', '<a>'));
+
+?>
+--EXPECTF--
+string(47) "USD<input type="text"/>CDN<input type="text" />"
+bool(true)
+string(6) "USDCDN"
+string(0) ""