Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

reenable php_html_puts

  • Loading branch information...
commit a769454d79121a753ce92e5a0a60a8893189c968 1 parent 3a838c7
Sascha Schumann authored
View
13 ext/standard/info.c
@@ -67,6 +67,7 @@ static void php_print_gpcse_array(char *name, uint name_length TSRMLS_DC)
{
zval **data, **tmp, tmp2;
char *string_key;
+ uint string_len;
ulong num_key;
if (zend_hash_find(&EG(symbol_table), name, name_length+1, (void **) &data)!=FAILURE
@@ -77,9 +78,9 @@ static void php_print_gpcse_array(char *name, uint name_length TSRMLS_DC)
PUTS("<td bgcolor=\"" PHP_ENTRY_NAME_COLOR "\"><b>");
PUTS(name);
PUTS("[\"");
- switch (zend_hash_get_current_key(Z_ARRVAL_PP(data), &string_key, &num_key, 0)) {
+ switch (zend_hash_get_current_key_ex(Z_ARRVAL_PP(data), &string_key, &string_len, &num_key, 0, NULL)) {
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);
@@ -94,10 +95,10 @@ static void php_print_gpcse_array(char *name, uint name_length TSRMLS_DC)
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("&nbsp;</td></tr>\n");
zend_hash_move_forward(Z_ARRVAL_PP(data));
@@ -290,7 +291,7 @@ PHPAPI void php_print_info(int flag TSRMLS_DC)
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);
}
@@ -482,7 +483,7 @@ PHPAPI void php_info_print_table_row(int num_cols, ...)
if (!row_element || !*row_element) {
php_printf("&nbsp;");
} 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>":""));
View
48 main/main.c
@@ -377,12 +377,54 @@ PHPAPI int php_printf(const char *format, ...)
}
/* }}} */
-
/* {{{ php_html_puts */
-/* wrapper for backwards compatibility */
+#include "ext/standard/php_smart_str.h"
+
PHPAPI void php_html_puts(const char *str, uint size TSRMLS_DC)
{
- zend_html_puts(str, size);
+ const char *end = str+size;
+ const char *p = str;
+ smart_str s = {0};
+
+ while (p < end) {
+ switch (*p) {
+ case '\n':
+ smart_str_appendl(&s, "<br />", sizeof("<br />")-1);
+ break;
+ case '<':
+ smart_str_appendl(&s, "&lt;", sizeof("&lt;")-1);
+ break;
+ case '>':
+ smart_str_appendl(&s, "&gt;", sizeof("&gt;")-1);
+ break;
+ case '&':
+ smart_str_appendl(&s, "&amp;", sizeof("&amp;")-1);
+ break;
+ case ' ': {
+ const char *nextchar = p+1, *prevchar = p-1;
+
+ /* series of spaces should be converted to &nbsp;'s */
+ if (((nextchar < end) && *nextchar==' ')
+ || ((prevchar >= str) && *prevchar==' ')) {
+ smart_str_appendl(&s, "&nbsp;", sizeof("&nbsp;")-1);
+ } else {
+ smart_str_appendc(&s, ' ');
+ }
+ }
+ break;
+ case '\t':
+ smart_str_appendl(&s, "&nbsp;&nbsp;&nbsp;&nbsp;", sizeof("&nbsp;&nbsp;&nbsp;&nbsp;")-1);
+ break;
+ default:
+ smart_str_appendc(&s, *p);
+ }
+ p++;
+ }
+
+ if (s.c) {
+ PHPWRITE(s.c, s.len);
+ smart_str_free(&s);
+ }
}
/* }}} */
View
2  main/php_ini.c
@@ -74,7 +74,7 @@ static void php_ini_displayer_cb(zend_ini_entry *ini_entry, int type)
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 {
PHPWRITE(display_string, display_string_length);
}
View
2  main/php_main.h
@@ -45,6 +45,8 @@ PHPAPI int php_lint_script(zend_file_handle *file TSRMLS_DC);
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);
/* environment module */
Please sign in to comment.
Something went wrong with that request. Please try again.