From 10ef118e09435a6fa7815a40829126490d9a7d67 Mon Sep 17 00:00:00 2001
From: Ryan Dwyer <ryandwyer1@gmail.com>
Date: Fri, 21 Sep 2018 21:27:36 +1000
Subject: Fix pango escaping and refactor escape_markup_text

Fixes #2674.

The cause of the issue was in get_pango_layout. When we call
pango_parse_markup, `text` is the escaped string, and the unescaped
string is then computed and written to `buf`. We were then passing the
unescaped string to pango_layout_set_markup, but this function needs the
escaped string. `buf` is not needed and has been removed.

The other part of this PR refactors escape_markup_text to remove the
dest_length argument and removes the -1 return value on error. It now
assumes that you've allocated dest to the correct length.
---
 sway/tree/view.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

(limited to 'sway/tree')

diff --git a/sway/tree/view.c b/sway/tree/view.c
index 4398f518..f61f5c84 100644
--- a/sway/tree/view.c
+++ b/sway/tree/view.c
@@ -785,14 +785,9 @@ static size_t parse_title_format(struct sway_view *view, char *buffer) {
 }
 
 static char *escape_title(char *buffer) {
-	int length = escape_markup_text(buffer, NULL, 0);
+	size_t length = escape_markup_text(buffer, NULL);
 	char *escaped_title = calloc(length + 1, sizeof(char));
-	int result = escape_markup_text(buffer, escaped_title, length);
-	if (result != length) {
-		wlr_log(WLR_ERROR, "Could not escape title: %s", buffer);
-		free(escaped_title);
-		return buffer;
-	}
+	escape_markup_text(buffer, escaped_title);
 	free(buffer);
 	return escaped_title;
 }
-- 
cgit v1.2.3