summaryrefslogtreecommitdiffstats
path: root/save-xml.c
diff options
context:
space:
mode:
authorGravatar Gehad elrobey <gehadelrobey@gmail.com>2014-06-02 20:10:54 +0300
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-06-06 10:08:09 -0700
commit464a611d8d5dbef8c3d62320f7b89e6c4ffaab53 (patch)
treeb4c5e4a1221a9a3576215677ce762d5daf1bea7c /save-xml.c
parent1120379b2bcdc2d941bb2e036bacf34d226e74a1 (diff)
downloadsubsurface-464a611d8d5dbef8c3d62320f7b89e6c4ffaab53.tar.gz
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>
Diffstat (limited to 'save-xml.c')
-rw-r--r--save-xml.c45
1 files changed, 2 insertions, 43 deletions
diff --git a/save-xml.c b/save-xml.c
index d48d0ef08..9f2c2b46a 100644
--- a/save-xml.c
+++ b/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 = "&lt;";
- break;
- case '>':
- escape = "&gt;";
- break;
- case '&':
- escape = "&amp;";
- break;
- case '\'':
- if (!is_attribute)
- continue;
- escape = "&apos;";
- break;
- case '\"':
- if (!is_attribute)
- continue;
- escape = "&quot;";
- 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)