From 982c510cd9cc403efd6e85d6738a1b83c5c73076 Mon Sep 17 00:00:00 2001 From: Colin Viebrock Date: Thu, 26 Sep 2002 19:33:23 +0000 Subject: [PATCH] update credits page with proper HTML, fix HTML escaping, and a few tweaks --- ext/standard/credits.c | 8 ++-- ext/standard/info.c | 95 ++++++++++++++++++++++++++++-------------- ext/standard/info.h | 2 + 3 files changed, 68 insertions(+), 37 deletions(-) diff --git a/ext/standard/credits.c b/ext/standard/credits.c index d6239efd0c..4fbde72c19 100644 --- a/ext/standard/credits.c +++ b/ext/standard/credits.c @@ -31,12 +31,10 @@ PHPAPI void php_print_credits(int flag) TSRMLS_FETCH(); if (flag & PHP_CREDITS_FULLPAGE) { - PUTS("PHP Credits\n"); + php_print_info_htmlhead(); } - php_info_print_style(); - - PUTS("

PHP 4 Credits

\n"); + PUTS("

PHP Credits

\n"); if (flag & PHP_CREDITS_GROUP) { /* Group */ @@ -110,7 +108,7 @@ PHPAPI void php_print_credits(int flag) } if (flag & PHP_CREDITS_FULLPAGE) { - PUTS("\n"); + PUTS("\n"); } } /* }}} */ diff --git a/ext/standard/info.c b/ext/standard/info.c index 4f21a76f41..4b4b292904 100644 --- a/ext/standard/info.c +++ b/ext/standard/info.c @@ -24,6 +24,7 @@ #include "php_ini.h" #include "php_globals.h" #include "ext/standard/head.h" +#include "ext/standard/html.h" #include "info.h" #include "credits.h" #include "css.h" @@ -35,7 +36,6 @@ #endif #include "zend_globals.h" /* needs ELS */ #include "zend_extensions.h" -#include "zend_highlight.h" #ifdef HAVE_SYS_UTSNAME_H #include #endif @@ -115,7 +115,7 @@ static void php_print_gpcse_array(char *name, uint name_length TSRMLS_DC) switch (zend_hash_get_current_key_ex(Z_ARRVAL_PP(data), &string_key, &string_len, &num_key, 0, NULL)) { case HASH_KEY_IS_STRING: if (PG(html_errors)) { - zend_html_puts(string_key, string_len-1); + PUTS(php_info_html_esc( string_key )); } else { PUTS(string_key); } @@ -146,7 +146,7 @@ static void php_print_gpcse_array(char *name, uint name_length TSRMLS_DC) if (Z_STRLEN(tmp2) == 0) { PUTS("no value"); } else { - zend_html_puts(Z_STRVAL(tmp2), Z_STRLEN(tmp2)); + PUTS(php_info_html_esc( Z_STRVAL(tmp2) )); } } else { PUTS(Z_STRVAL(tmp2)); @@ -157,7 +157,7 @@ static void php_print_gpcse_array(char *name, uint name_length TSRMLS_DC) if (Z_STRLEN_PP(tmp) == 0) { PUTS("no value"); } else { - zend_html_puts(Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp)); + PUTS(php_info_html_esc( Z_STRVAL_PP(tmp) )); } } else { PUTS(Z_STRVAL_PP(tmp)); @@ -184,6 +184,17 @@ void php_info_print_style(void) } /* }}} */ + +/* {{{ php_info_html_esc + */ +PHPAPI char *php_info_html_esc(char *string) +{ + int new_len; + return php_escape_html_entities(string, strlen(string), &new_len, 1, ENT_COMPAT, NULL); +} +/* }}} */ + + /* {{{ php_get_uname */ PHPAPI char *php_get_uname(char mode) @@ -260,50 +271,64 @@ PHPAPI char *php_get_uname(char mode) } /* }}} */ -/* {{{ php_print_info + +/* {{{ php_print_info_htmlhead */ -PHPAPI void php_print_info(int flag TSRMLS_DC) +PHPAPI void php_print_info_htmlhead() { - char **env, *tmp1, *tmp2; const char *charset = NULL; - char *php_uname; - int expose_php = INI_INT("expose_php"); - time_t the_time; - struct tm *ta, tmbuf; + if (SG(default_charset)) { + charset = SG(default_charset); + } - the_time = time(NULL); - ta = php_localtime_r(&the_time, &tmbuf); - if (PG(html_errors)) { - PUTS(""); - PUTS(""); - PUTS(""); - php_info_print_style(); - if (SG(default_charset)) { - charset = SG(default_charset); - } #if HAVE_MBSTRING - if (php_ob_handler_used("mb_output_handler" TSRMLS_CC)) { - if (MBSTRG(current_http_output_encoding) == mbfl_no_encoding_pass) { - charset = "US-ASCII"; - } else { - charset = mbfl_no2preferred_mime_name(MBSTRG(current_http_output_encoding)); - } + if (php_ob_handler_used("mb_output_handler" TSRMLS_CC)) { + if (MBSTRG(current_http_output_encoding) == mbfl_no_encoding_pass) { + charset = "US-ASCII"; + } else { + charset = mbfl_no2preferred_mime_name(MBSTRG(current_http_output_encoding)); } + } #endif - } + #if HAVE_ICONV if (php_ob_handler_used("ob_iconv_handler" TSRMLS_CC)) { charset = ICONVG(output_encoding); } #endif + if (!charset || !charset[0]) { charset = "US-ASCII"; } + PUTS("\n"); + PUTS(""); + PUTS("\n"); + php_info_print_style(); + PUTS("phpinfo()"); + php_printf("\n", charset); + PUTS("\n"); + PUTS("
\n"); +} +/* }}} */ + + +/* {{{ php_print_info + */ +PHPAPI void php_print_info(int flag TSRMLS_DC) +{ + char **env, *tmp1, *tmp2; + char *php_uname; + int expose_php = INI_INT("expose_php"); + time_t the_time; + struct tm *ta, tmbuf; + + the_time = time(NULL); + ta = php_localtime_r(&the_time, &tmbuf); + if (PG(html_errors)) { - php_printf("phpinfo()\n", charset); - PUTS("
\n"); + php_print_info_htmlhead(); } else { PUTS(" _ _ __ ____ \n"); PUTS(" _ __ | |__ _ __ (_)_ __ / _| ___ / /\\ \\ \n"); @@ -646,7 +671,9 @@ PHPAPI void php_info_print_table_header(int num_cols, ...) row_element = " "; } if (PG(html_errors)) { - php_printf("%s", row_element); + PUTS(""); + PUTS(php_info_html_esc( row_element )); + PUTS(""); } else { PUTS(row_element); if (i < num_cols-1) { @@ -671,6 +698,10 @@ PHPAPI void php_info_print_table_row(int num_cols, ...) int i; va_list row_elements; char *row_element; +/* + char *elem_esc; + int elem_esc_len; +*/ TSRMLS_FETCH(); @@ -693,7 +724,7 @@ PHPAPI void php_info_print_table_row(int num_cols, ...) } } else { if (PG(html_errors)) { - zend_html_puts(row_element, strlen(row_element)); + PUTS(php_info_html_esc( row_element )); } else { PUTS(row_element); if (i < num_cols-1) { diff --git a/ext/standard/info.h b/ext/standard/info.h index 7e7c7ebf4b..580e1b8c92 100644 --- a/ext/standard/info.h +++ b/ext/standard/info.h @@ -63,6 +63,8 @@ PHP_FUNCTION(zend_logo_guid); PHP_FUNCTION(php_egg_logo_guid); PHP_FUNCTION(php_sapi_name); PHP_FUNCTION(php_uname); +PHPAPI char *php_info_html_esc(char *string); +PHPAPI void php_print_info_htmlhead(void); PHPAPI void php_print_info(int flag TSRMLS_DC); PHPAPI void php_print_style(void); PHPAPI void php_info_print_style(void); -- 2.40.0