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
45
save-xml.c
45
save-xml.c
|
@ -23,49 +23,8 @@
|
|||
*/
|
||||
static void quote(struct membuffer *b, const char *text, int is_attribute)
|
||||
{
|
||||
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;
|
||||
}
|
||||
put_bytes(b, text, (p - text - 1));
|
||||
if (!escape)
|
||||
break;
|
||||
put_string(b, escape);
|
||||
text = p;
|
||||
}
|
||||
int is_html = 0;
|
||||
put_quoted(b, text, is_attribute, is_html);
|
||||
}
|
||||
|
||||
static void show_utf8(struct membuffer *b, const char *text, const char *pre, const char *post, int is_attribute)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue