1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-12-04 14:46:47 -05:00

add_html_to_string: Do not encode bytes 0x80...0xFF.

Reported by Witold Filipczyk.
This commit is contained in:
Kalle Olavi Niemitalo 2007-03-19 08:32:43 +02:00 committed by Witold Filipczyk
parent 65efed3e83
commit 81cb9155d2
2 changed files with 7 additions and 2 deletions

View File

@ -275,7 +275,7 @@ struct string *
add_html_to_string(struct string *string, const unsigned char *src, int len) add_html_to_string(struct string *string, const unsigned char *src, int len)
{ {
for (; len; len--, src++) { for (; len; len--, src++) {
if (*src < 0x20 || *src >= 0x7F if (*src < 0x20
|| *src == '<' || *src == '>' || *src == '&' || *src == '<' || *src == '>' || *src == '&'
|| *src == '\"' || *src == '\'') { || *src == '\"' || *src == '\'') {
int rollback_length = string->length; int rollback_length = string->length;

View File

@ -76,7 +76,12 @@ add_string_replace(struct string *string, unsigned char *src, int len,
#define add_real_optname_to_string(str, src, len) \ #define add_real_optname_to_string(str, src, len) \
add_string_replace(str, src, len, '*', '.') add_string_replace(str, src, len, '*', '.')
/* Convert reserved chars to html &#xx */ /* Convert reserved chars to html &#xx;. This function copies bytes
* 0x80...0xFF unchanged, so the caller should ensure that the
* resulting HTML will be parsed with the same charset as the original
* string. (This function cannot use the &#160; syntax for non-ASCII,
* because HTML wants Unicode numbers there and this function does not
* know the charset of the input data.) */
struct string *add_html_to_string(struct string *string, const unsigned char *html, int htmllen); struct string *add_html_to_string(struct string *string, const unsigned char *html, int htmllen);
/* Escapes \ and " with a \ */ /* Escapes \ and " with a \ */