iliaa Mon Dec 18 15:02:16 2006 UTC
Modified files: (Branch: PHP_5_2)
/php-src/ext/filter sanitizing_filters.c
/php-src/ext/standard string.c php_string.h
Log:
Less hackish support for spaces at the start of tags within strip_tags()
http://cvs.php.net/viewvc.cgi/php-src/ext/filter/sanitizing_filters.c?r1=1.11.2.6&r2=1.11.2.7&diff_format=u
Index: php-src/ext/filter/sanitizing_filters.c
diff -u php-src/ext/filter/sanitizing_filters.c:1.11.2.6
php-src/ext/filter/sanitizing_filters.c:1.11.2.7
--- php-src/ext/filter/sanitizing_filters.c:1.11.2.6 Mon Dec 18 04:22:04 2006
+++ php-src/ext/filter/sanitizing_filters.c Mon Dec 18 15:02:16 2006
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: sanitizing_filters.c,v 1.11.2.6 2006/12/18 04:22:04 iliaa Exp $ */
+/* $Id: sanitizing_filters.c,v 1.11.2.7 2006/12/18 15:02:16 iliaa Exp $ */
#include "php_filter.h"
#include "filter_private.h"
@@ -179,7 +179,7 @@
php_filter_encode_html(value, enc);
/* strip tags, implicitly also removes \0 chars */
- new_len = php_strip_tags(Z_STRVAL_P(value), Z_STRLEN_P(value), NULL,
NULL, -1);
+ new_len = php_strip_tags_ex(Z_STRVAL_P(value), Z_STRLEN_P(value), NULL,
NULL, 0, 1);
Z_STRLEN_P(value) = new_len;
if (new_len == 0) {
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/string.c?r1=1.445.2.14.2.32&r2=1.445.2.14.2.33&diff_format=u
Index: php-src/ext/standard/string.c
diff -u php-src/ext/standard/string.c:1.445.2.14.2.32
php-src/ext/standard/string.c:1.445.2.14.2.33
--- php-src/ext/standard/string.c:1.445.2.14.2.32 Mon Dec 18 04:22:04 2006
+++ php-src/ext/standard/string.c Mon Dec 18 15:02:16 2006
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: string.c,v 1.445.2.14.2.32 2006/12/18 04:22:04 iliaa Exp $ */
+/* $Id: string.c,v 1.445.2.14.2.33 2006/12/18 15:02:16 iliaa Exp $ */
/* Synced with php 3.0 revision 1.193 1999-06-16 [ssb] */
@@ -3890,7 +3890,7 @@
}
convert_to_string_ex(str);
buf = estrndup(Z_STRVAL_PP(str), Z_STRLEN_PP(str));
- retval_len = php_strip_tags(buf, Z_STRLEN_PP(str), NULL, allowed_tags,
allowed_tags_len);
+ retval_len = php_strip_tags_ex(buf, Z_STRLEN_PP(str), NULL,
allowed_tags, allowed_tags_len, 0);
RETURN_STRINGL(buf, retval_len, 0);
}
/* }}} */
@@ -4095,6 +4095,11 @@
}
/* }}} */
+PHPAPI size_t php_strip_tags(char *rbuf, int len, int *stateptr, char *allow,
int allow_len)
+{
+ return php_strip_tags_ex(rbuf, len, stateptr, allow, allow_len, 0);
+}
+
/* {{{ php_strip_tags
A simple little state-machine to strip out html and php tags
@@ -4115,7 +4120,7 @@
swm: Added ability to strip <?xml tags without assuming it PHP
code.
*/
-PHPAPI size_t php_strip_tags(char *rbuf, int len, int *stateptr, char *allow,
int allow_len)
+PHPAPI size_t php_strip_tags_ex(char *rbuf, int len, int *stateptr, char
*allow, int allow_len, zend_bool allow_tag_spaces)
{
char *tbuf, *buf, *p, *tp, *rp, c, lc;
int br, i=0, depth=0;
@@ -4143,7 +4148,7 @@
case '\0':
break;
case '<':
- if (isspace(*(p + 1)) && allow_len >=- 0) {
+ if (isspace(*(p + 1)) && !allow_tag_spaces) {
goto reg_char;
}
if (state == 0) {
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/php_string.h?r1=1.87.2.2.2.1&r2=1.87.2.2.2.2&diff_format=u
Index: php-src/ext/standard/php_string.h
diff -u php-src/ext/standard/php_string.h:1.87.2.2.2.1
php-src/ext/standard/php_string.h:1.87.2.2.2.2
--- php-src/ext/standard/php_string.h:1.87.2.2.2.1 Mon Aug 28 23:33:37 2006
+++ php-src/ext/standard/php_string.h Mon Dec 18 15:02:16 2006
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_string.h,v 1.87.2.2.2.1 2006/08/28 23:33:37 iliaa Exp $ */
+/* $Id: php_string.h,v 1.87.2.2.2.2 2006/12/18 15:02:16 iliaa Exp $ */
/* Synced with php 3.0 revision 1.43 1999-06-16 [ssb] */
@@ -132,6 +132,7 @@
int needle_len, char *str, int str_len, int *_new_length);
PHPAPI char *php_trim(char *c, int len, char *what, int what_len, zval
*return_value, int mode TSRMLS_DC);
PHPAPI size_t php_strip_tags(char *rbuf, int len, int *state, char *allow, int
allow_len);
+PHPAPI size_t php_strip_tags_ex(char *rbuf, int len, int *stateptr, char
*allow, int allow_len, zend_bool allow_tag_spaces);
PHPAPI int php_char_to_str_ex(char *str, uint len, char from, char *to, int
to_len, zval *result, int case_sensitivity, int *replace_count);
PHPAPI int php_char_to_str(char *str, uint len, char from, char *to, int
to_len, zval *result);
PHPAPI void php_implode(zval *delim, zval *arr, zval *return_value TSRMLS_DC);
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php