diff options
author | Sascha Schumann <sas@php.net> | 2002-05-12 14:48:22 +0000 |
---|---|---|
committer | Sascha Schumann <sas@php.net> | 2002-05-12 14:48:22 +0000 |
commit | a769454d79121a753ce92e5a0a60a8893189c968 (patch) | |
tree | bdc4eddcb3a1799c4035c53d7edc665d0f5bdcca /main | |
parent | 3a838c773775e24082e55a551d885e2906b42d8a (diff) | |
download | php-git-a769454d79121a753ce92e5a0a60a8893189c968.tar.gz |
reenable php_html_puts
Diffstat (limited to 'main')
-rw-r--r-- | main/main.c | 48 | ||||
-rw-r--r-- | main/php_ini.c | 2 | ||||
-rw-r--r-- | main/php_main.h | 2 |
3 files changed, 48 insertions, 4 deletions
diff --git a/main/main.c b/main/main.c index 96411157ba..26c21068b8 100644 --- a/main/main.c +++ b/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, "<", sizeof("<")-1); + break; + case '>': + smart_str_appendl(&s, ">", sizeof(">")-1); + break; + case '&': + smart_str_appendl(&s, "&", sizeof("&")-1); + break; + case ' ': { + const char *nextchar = p+1, *prevchar = p-1; + + /* series of spaces should be converted to 's */ + if (((nextchar < end) && *nextchar==' ') + || ((prevchar >= str) && *prevchar==' ')) { + smart_str_appendl(&s, " ", sizeof(" ")-1); + } else { + smart_str_appendc(&s, ' '); + } + } + break; + case '\t': + smart_str_appendl(&s, " ", sizeof(" ")-1); + break; + default: + smart_str_appendc(&s, *p); + } + p++; + } + + if (s.c) { + PHPWRITE(s.c, s.len); + smart_str_free(&s); + } } /* }}} */ diff --git a/main/php_ini.c b/main/php_ini.c index 6610775a68..78d7023f94 100644 --- a/main/php_ini.c +++ b/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); } diff --git a/main/php_main.h b/main/php_main.h index ea9137c5f8..0ae80136cd 100644 --- a/main/php_main.h +++ b/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 */ |