Gehad's patches
Dirk Hohndel
dirk at hohndel.org
Tue Jun 3 21:15:34 PDT 2014
On Tue, Jun 03, 2014 at 09:12:36PM +0300, Miika Turkia wrote:
> From 684bdf422b466763045a25179b0ee022c9cb5cf3 Mon Sep 17 00:00:00 2001
> From: Gehad elrobey <gehadelrobey at gmail.com>
> Date: Mon, 2 Jun 2014 20:10:54 +0300
> Subject: [PATCH 6/7] HTML: Better quoting to the export strings
>
> Quote the location, buddy, suit, tags and notes.
> This prevents JS code from crashing.
>
> Signed-off-by: Gehad elrobey <gehadelrobey at gmail.com>
> Signed-off-by: Miika Turkia <miika.turkia at gmail.com>
>
> -char *replace_char(char *str, char replace, char *replace_by)
> +void put_quoted(struct membuffer *b, const char *text)
> {
> + 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 '\'':
> + escape = "'";
> + break;
> + case '\"':
> + escape = """;
> + break;
> + case '\n':
> + escape = "<br>";
> + break;
> + }
> + put_bytes(b, text, (p - text - 1));
> + if (!escape)
> + break;
> + put_string(b, escape);
> + text = p;
> }
This is more or less verbatim the quote() function from save-xml.c.
Why not just call that function (or have a wrapper around it)?
I hate the idea of having basically identical quote twice.
I took the other patches, this one I would like to see redone.
/D
More information about the subsurface
mailing list