From b0a61c843a54681ac207009d8fbc74f0f240513f Mon Sep 17 00:00:00 2001 From: Patrick McDermott Date: Tue, 31 Oct 2017 00:51:24 -0400 Subject: view-source: Escape markup --- (limited to 'src') 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 = "\n" "\n" "\n" @@ -43,9 +43,7 @@ const gchar *document_begin = "\n" "\n" "
\n"
-				"\n";
-const gchar *document_end =
-				"\n"
+				"%s\n"
 			"
\n" "\n" "\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); -- cgit v0.9.1