mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
HTML: Better quoting to the export strings
Move the quote function to membuffer.c and adding wrappers that call it from both xml and html exporters to get rid of redundancy. Quote the location, buddy, suit, tags and notes This prevents js code from crashing. [Miika Turkia: minor whitespace and code fix] Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com> Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
1120379b2b
commit
464a611d8d
6 changed files with 73 additions and 104 deletions
56
membuffer.c
56
membuffer.c
|
|
@ -96,7 +96,7 @@ void put_vformat(struct membuffer *b, const char *fmt, va_list args)
|
|||
return;
|
||||
}
|
||||
|
||||
room = len+1;
|
||||
room = len + 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -174,5 +174,57 @@ void put_degrees(struct membuffer *b, degrees_t value, const char *pre, const ch
|
|||
udeg = -udeg;
|
||||
sign = "-";
|
||||
}
|
||||
put_format(b,"%s%s%u.%06u%s", pre, sign, FRACTION(udeg, 1000000), post);
|
||||
put_format(b, "%s%s%u.%06u%s", pre, sign, FRACTION(udeg, 1000000), post);
|
||||
}
|
||||
|
||||
void put_quoted(struct membuffer *b, const char *text, int is_attribute, int is_html)
|
||||
{
|
||||
const char *p = text;
|
||||
|
||||
for (;;) {
|
||||
const char *escape;
|
||||
|
||||
switch (*p++) {
|
||||
default:
|
||||
continue;
|
||||
case 0:
|
||||
escape = NULL;
|
||||
break;
|
||||
case 1 ... 8:
|
||||
case 11:
|
||||
case 12:
|
||||
case 14 ... 31:
|
||||
escape = "?";
|
||||
break;
|
||||
case '<':
|
||||
escape = "<";
|
||||
break;
|
||||
case '>':
|
||||
escape = ">";
|
||||
break;
|
||||
case '&':
|
||||
escape = "&";
|
||||
break;
|
||||
case '\'':
|
||||
if (!is_attribute)
|
||||
continue;
|
||||
escape = "'";
|
||||
break;
|
||||
case '\"':
|
||||
if (!is_attribute)
|
||||
continue;
|
||||
escape = """;
|
||||
break;
|
||||
case '\n':
|
||||
if (!is_html)
|
||||
continue;
|
||||
else
|
||||
escape = "<br>";
|
||||
}
|
||||
put_bytes(b, text, (p - text - 1));
|
||||
if (!escape)
|
||||
break;
|
||||
put_string(b, escape);
|
||||
text = p;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue