summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrick McDermott <pj@pehjota.net>2017-10-31 00:51:24 (EDT)
committer Patrick McDermott <pj@pehjota.net>2017-10-31 00:51:24 (EDT)
commitb0a61c843a54681ac207009d8fbc74f0f240513f (patch)
tree14b33b43c4eeff7579d8df738f5bcd59c6fc53cf
parent7c0f2d7b55db80f060321c69cf8120489cb45f8c (diff)
downloadmarquee-b0a61c843a54681ac207009d8fbc74f0f240513f.zip
marquee-b0a61c843a54681ac207009d8fbc74f0f240513f.tar.gz
marquee-b0a61c843a54681ac207009d8fbc74f0f240513f.tar.bz2
view-source: Escape markup
-rw-r--r--src/view-source.c17
1 files changed, 7 insertions, 10 deletions
diff --git a/src/view-source.c b/src/view-source.c
index 5d4372b..bace681 100644
--- a/src/view-source.c
+++ b/src/view-source.c
@@ -34,7 +34,7 @@ typedef struct {
gulong handler_id;
} DataSignalData;
-const gchar *document_begin =
+static const gchar *document =
"<!doctype html>\n"
"<html dir=\"%s\">\n"
"<head>\n"
@@ -43,9 +43,7 @@ const gchar *document_begin =
"</head>\n"
"<body>\n"
"<pre>\n"
- "<code>\n";
-const gchar *document_end =
- "</code>\n"
+ "<code>%s</code>\n"
"</pre>\n"
"</body>\n"
"</html>\n";
@@ -53,17 +51,16 @@ const gchar *document_end =
static void
respond(WebKitURISchemeRequest *request, guchar *data, gsize length)
{
+ gchar *escaped_data;
GInputStream *stream;
+ escaped_data = g_markup_escape_text((gchar *) data, length);
+
stream = g_memory_input_stream_new_from_data(
- g_strdup_printf(document_begin,
+ g_strdup_printf(document,
gtk_widget_get_default_direction() ==
GTK_TEXT_DIR_RTL ? "rtl" : "ltr",
- "TODO"), -1, g_free);
- g_memory_input_stream_add_data(G_MEMORY_INPUT_STREAM(stream),
- data, length, g_free);
- g_memory_input_stream_add_data(G_MEMORY_INPUT_STREAM(stream),
- document_end, -1, NULL);
+ "TODO", escaped_data), -1, g_free);
webkit_uri_scheme_request_finish(request, stream, -1, "text/html");
g_object_unref(stream);