summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-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);