cvs: php4 /ext/standard info.c /main main.c php_ini.c php_main.h
| From: | Sascha Schumann | Date: | Mon, 04 Mar 2002 18:46:59 +0000 |
| Subject: | cvs: php4 /ext/standard info.c /main main.c php_ini.c php_main.h | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-9648@lists.php.net to get a copy of this message | ||
sas Mon Mar 4 13:46:59 2002 EDT
Modified files:
/php4/ext/standard info.c
/php4/main main.c php_ini.c php_main.h
Log:
Supply php_html_puts which escapes a whole string.. now fully works in ZTS
mode, too.
Index: php4/ext/standard/info.c
diff -u php4/ext/standard/info.c:1.165 php4/ext/standard/info.c:1.166
--- php4/ext/standard/info.c:1.165 Mon Mar 4 13:12:55 2002
+++ php4/ext/standard/info.c Mon Mar 4 13:46:53 2002
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: info.c,v 1.165 2002/03/04 18:12:55 sas Exp $ */
+/* $Id: info.c,v 1.166 2002/03/04 18:46:53 sas Exp $ */
#include "php.h"
#include "php_ini.h"
@@ -74,7 +74,7 @@
PUTS("[\"");
switch (zend_hash_get_current_key(Z_ARRVAL_PP(data), &string_key, &num_key, 0)) {
case HASH_KEY_IS_STRING:
- zend_html_puts(string_key, strlen(string_key));
+ php_html_puts(string_key, strlen(string_key) TSRMLS_CC);
break;
case HASH_KEY_IS_LONG:
php_printf("%ld", num_key);
@@ -89,10 +89,10 @@
tmp2 = **tmp;
zval_copy_ctor(&tmp2);
convert_to_string(&tmp2);
- zend_html_puts(Z_STRVAL(tmp2), Z_STRLEN(tmp2));
+ php_html_puts(Z_STRVAL(tmp2), Z_STRLEN(tmp2) TSRMLS_CC);
zval_dtor(&tmp2);
} else {
- zend_html_puts(Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp));
+ php_html_puts(Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp) TSRMLS_CC);
}
PUTS(" </td></tr>\n");
zend_hash_move_forward(Z_ARRVAL_PP(data));
@@ -226,7 +226,7 @@
PUTS("?="ZEND_LOGO_GUID"\" border=\"0\" align=\"right\"
alt=\"Zend logo\"></a>\n");
}
php_printf("This program makes use of the Zend Scripting Language Engine:<br
/>");
- zend_html_puts(zend_version, strlen(zend_version));
+ php_html_puts(zend_version, strlen(zend_version) TSRMLS_CC);
php_info_print_box_end();
efree(php_uname);
}
@@ -404,6 +404,7 @@
int i;
va_list row_elements;
char *row_element;
+ TSRMLS_FETCH();
va_start(row_elements, num_cols);
@@ -417,7 +418,7 @@
if (!row_element || !*row_element) {
php_printf(" ");
} else {
- zend_html_puts(row_element, strlen(row_element));
+ php_html_puts(row_element, strlen(row_element) TSRMLS_CC);
}
php_printf("%s</td>", (i==0?"</b>":""));
Index: php4/main/main.c
diff -u php4/main/main.c:1.427 php4/main/main.c:1.428
--- php4/main/main.c:1.427 Fri Mar 1 14:29:35 2002
+++ php4/main/main.c Mon Mar 4 13:46:54 2002
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: main.c,v 1.427 2002/03/01 19:29:35 edink Exp $ */
+/* $Id: main.c,v 1.428 2002/03/04 18:46:54 sas Exp $ */
/* {{{ includes
*/
@@ -356,6 +356,46 @@
va_end(args);
return ret;
+}
+/* }}} */
+
+/* {{{ php_html_puts */
+#include "ext/standard/php_smart_str.h"
+
+PHPAPI void php_html_puts(const char *str, uint size TSRMLS_DC)
+{
+ const char *estr;
+ smart_str s = {0};
+
+ for (estr = str + size; str < estr; str++) {
+ switch (*str) {
+ case '\n':
+ smart_str_appendl(&s, "<br />", sizeof("<br />")-1);
+ break;
+ case '<':
+ smart_str_appends(&s, "<");
+ break;
+ case '>':
+ smart_str_appends(&s, ">");
+ break;
+ case '&':
+ smart_str_appends(&s, "&");
+ break;
+ case ' ':
+ smart_str_appendl(&s, " ", sizeof(" ")-1);
+ break;
+ case '\t':
+ smart_str_appends(&s, " ");
+ break;
+ default:
+ smart_str_appendc(&s, *str);
+ }
+ }
+
+ if (s.c) {
+ PHPWRITE(s.c, s.len);
+ smart_str_free(&s);
+ }
}
/* }}} */
Index: php4/main/php_ini.c
diff -u php4/main/php_ini.c:1.78 php4/main/php_ini.c:1.79
--- php4/main/php_ini.c:1.78 Thu Feb 28 07:12:39 2002
+++ php4/main/php_ini.c Mon Mar 4 13:46:55 2002
@@ -49,6 +49,7 @@
} else {
char *display_string;
uint display_string_length, esc_html=0;
+ TSRMLS_FETCH();
if (type==ZEND_INI_DISPLAY_ORIG && ini_entry->modified) {
if (ini_entry->orig_value && ini_entry->orig_value[0]) {
@@ -68,9 +69,8 @@
display_string_length = sizeof("<i>no value</i>")-1;
}
if(esc_html) {
- zend_html_puts(display_string, display_string_length);
+ php_html_puts(display_string, display_string_length TSRMLS_CC);
} else {
- TSRMLS_FETCH();
PHPWRITE(display_string, display_string_length);
}
}
Index: php4/main/php_main.h
diff -u php4/main/php_main.h:1.18 php4/main/php_main.h:1.19
--- php4/main/php_main.h:1.18 Tue Feb 26 14:38:41 2002
+++ php4/main/php_main.h Mon Mar 4 13:46:55 2002
@@ -18,7 +18,7 @@
*/
-/* $Id: php_main.h,v 1.18 2002/02/26 19:38:41 andi Exp $ */
+/* $Id: php_main.h,v 1.19 2002/03/04 18:46:55 sas Exp $ */
#ifndef PHP_MAIN_H
@@ -44,6 +44,8 @@
PHPAPI void php_handle_aborted_connection(void);
PHPAPI int php_handle_auth_data(const char *auth TSRMLS_DC);
+
+PHPAPI void php_html_puts(const char *str, uint siz TSRMLS_DC);
extern void php_call_shutdown_functions(void);