aboutsummaryrefslogtreecommitdiffstats
path: root/sway/tree/view.c
diff options
context:
space:
mode:
authorLibravatar emersion <contact@emersion.fr>2018-11-25 09:09:32 +0100
committerLibravatar emersion <contact@emersion.fr>2018-11-25 09:09:32 +0100
commitb84bf3585ce68784406ebe435dca5f67406db66e (patch)
treef763e37ce62bb9eca833808d3e1ff4f4d51ea8ba /sway/tree/view.c
parentMerge pull request #3179 from baloo/baloo/title_format-pango_markup (diff)
downloadsway-b84bf3585ce68784406ebe435dca5f67406db66e.tar.gz
sway-b84bf3585ce68784406ebe435dca5f67406db66e.tar.zst
sway-b84bf3585ce68784406ebe435dca5f67406db66e.zip
Fix pango title escaping
This commit fixes two bugs. First, commit [1] has inverted the condition when we escape pango markup. We need to escape client-provided strings when markup is enabled. Second, parse_title_format has a shortcut when title_format is set to `%title`, and escape_pango_markup wasn't used anymore there. Fixes https://github.com/swaywm/sway/issues/3181 [1]: https://github.com/swaywm/sway/pull/3179/commits/caee2dff03fc007dc46cf121e013f5347ac46ba9
Diffstat (limited to 'sway/tree/view.c')
-rw-r--r--sway/tree/view.c13
1 files changed, 4 insertions, 9 deletions
diff --git a/sway/tree/view.c b/sway/tree/view.c
index 63bb8e26..febba3b9 100644
--- a/sway/tree/view.c
+++ b/sway/tree/view.c
@@ -835,11 +835,10 @@ static size_t append_prop(char *buffer, const char *value) {
835 if (!value) { 835 if (!value) {
836 return 0; 836 return 0;
837 } 837 }
838 // if using pango_markup in font, we need to escape all markup char 838 // If using pango_markup in font, we need to escape all markup chars
839 // from values to avoid messing with pango markup 839 // from values to make sure tags are not inserted by clients
840 if (!config->pango_markup) { 840 if (config->pango_markup) {
841 char *escaped_value = escape_pango_markup(value); 841 char *escaped_value = escape_pango_markup(value);
842
843 lenient_strcat(buffer, escaped_value); 842 lenient_strcat(buffer, escaped_value);
844 size_t len = strlen(escaped_value); 843 size_t len = strlen(escaped_value);
845 free(escaped_value); 844 free(escaped_value);
@@ -856,11 +855,7 @@ static size_t append_prop(char *buffer, const char *value) {
856 */ 855 */
857static size_t parse_title_format(struct sway_view *view, char *buffer) { 856static size_t parse_title_format(struct sway_view *view, char *buffer) {
858 if (!view->title_format || strcmp(view->title_format, "%title") == 0) { 857 if (!view->title_format || strcmp(view->title_format, "%title") == 0) {
859 const char *title = view_get_title(view); 858 return append_prop(buffer, view_get_title(view));
860 if (buffer && title) {
861 strcpy(buffer, title);
862 }
863 return title ? strlen(title) : 0;
864 } 859 }
865 860
866 size_t len = 0; 861 size_t len = 0;