mirror of
https://github.com/php/php-src.git
synced 2024-11-26 11:23:47 +08:00
Removing HTMLization of ' ' wasn't ok, it didn't deal with series of spaces
properly. Turn series of spaces into 's.
This commit is contained in:
parent
19b7861d70
commit
77f41212f6
25
main/main.c
25
main/main.c
@ -382,11 +382,12 @@ PHPAPI int php_printf(const char *format, ...)
|
||||
|
||||
PHPAPI void php_html_puts(const char *str, uint size TSRMLS_DC)
|
||||
{
|
||||
const char *estr;
|
||||
const char *end = str+size;
|
||||
const char *p = str;
|
||||
smart_str s = {0};
|
||||
|
||||
for (estr = str + size; str < estr; str++) {
|
||||
switch (*str) {
|
||||
while (p < end) {
|
||||
switch (*p) {
|
||||
case '\n':
|
||||
smart_str_appendl(&s, "<br />", sizeof("<br />")-1);
|
||||
break;
|
||||
@ -399,19 +400,25 @@ PHPAPI void php_html_puts(const char *str, uint size TSRMLS_DC)
|
||||
case '&':
|
||||
smart_str_appendl(&s, "&", sizeof("&")-1);
|
||||
break;
|
||||
case ' ': {
|
||||
const char *nextchar = p+1, *prevchar = p-1;
|
||||
|
||||
/* Commented out since this is not necessary */
|
||||
/*
|
||||
case ' ':
|
||||
smart_str_appendl(&s, " ", sizeof(" ")-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, *str);
|
||||
smart_str_appendc(&s, *p);
|
||||
}
|
||||
p++;
|
||||
}
|
||||
|
||||
if (s.c) {
|
||||
|
Loading…
Reference in New Issue
Block a user