& must be encoded as &
[prss.git] / src / main.c
index 20b9b14..b9e6860 100644 (file)
@@ -32,6 +32,7 @@
 #include <config.h>
 #include "http.h"
 #include <plog.h>
+#include <pstr.h>
 #include "ttrss.h"
 #include "ttrss_ws.h"
 #include "webbrowser.h"
@@ -282,12 +283,25 @@ static struct headline *get_selected_headline(GtkTreeIter *iter)
        return NULL;
 }
 
+static char *headline_to_markup(struct headline *h)
+{
+       return strrepg(h->title, "&", "&amp;");
+}
+
 static char *headline_get_formated_headline(struct headline *h)
 {
+       char *tmp, *res;
+
+       tmp = headline_to_markup(h);
+
        if (h->unread)
-               return g_strdup_printf("<b>%s</b>", h->title);
+               res = g_strdup_printf("<b>%s</b>", tmp);
        else
-               return strdup(h->title);
+               res = strdup(tmp);
+
+       free(tmp);
+
+       return res;
 }
 
 static char *headline_get_date(struct headline *h)
@@ -367,7 +381,7 @@ int headline_cursor_changed_cbk(GtkTreeView *treeview, gpointer data)
        GtkTreeIter iter;
        GtkTreeModel *model;
        struct headline *headline;
-       char *str, *date;
+       char *str, *date, *title;
 
        log_debug("headline_cursor_changed_cbk()");
 
@@ -377,7 +391,9 @@ int headline_cursor_changed_cbk(GtkTreeView *treeview, gpointer data)
        headline = get_selected_headline(&iter);
 
        if (headline) {
-               gtk_label_set_text(w_headline_title, headline->title);
+               title = headline_to_markup(headline);
+               gtk_label_set_markup(w_headline_title, title);
+
                gtk_label_set_text(w_headline_date, ctime(&headline->date));
 
                str = ttrss_get_headline_content(headline);
@@ -398,11 +414,12 @@ int headline_cursor_changed_cbk(GtkTreeView *treeview, gpointer data)
                date = headline_get_date(headline);
                gtk_list_store_set(GTK_LIST_STORE(model),
                                   &iter,
-                                  COL_HEADLINE_TITLE, headline->title,
+                                  COL_HEADLINE_TITLE, title,
                                   COL_HEADLINE_DATE, date,
                                   COL_HEADLINE_EPOCH_TIME, headline->date,
                                   -1);
                free(date);
+               free(title);
        } else {
                log_debug("headline not found");
        }