After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 752920 - GtkLabel's warnings when parsing the markup failed are unhelpful
GtkLabel's warnings when parsing the markup failed are unhelpful
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Widget: GtkLabel
3.17.x
Other Linux
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2015-07-27 13:05 UTC by Timm Bäder
Modified: 2015-08-03 09:32 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
GtkLabel: Show erroneous text if parsing markup failed (1.37 KB, patch)
2015-07-27 13:05 UTC, Timm Bäder
accepted-commit_now Details | Review

Description Timm Bäder 2015-07-27 13:05:18 UTC
Created attachment 308212 [details] [review]
GtkLabel: Show erroneous text if parsing markup failed

So since I'm displaying random text I get from some webserver, I often run into issues because of non-escaped ampersand characters. GtkLabel prints warnings in this case, but I show many of them so I never know where the warnings come from.

It would be helpful if the warnings just included the text that it was trying to set.
Comment 1 Matthias Clasen 2015-07-27 18:05:46 UTC
Are you using g_markup_escape_text on your random text and still get non-escaped ampersands ? In that case, having some test cases would be nice.
Comment 2 Timm Bäder 2015-07-27 18:21:56 UTC
No, I just replace & with &, but I forget it now and then and int that case seeing which label causes the warning is helpful. The fact that ampersands need to be double-escaped in link titles (i.e. tooltips) doesn't really help -- they show up fine but still cause the warning to be printed. I'm not sure if the latter can be fixed in a backwards-compatible way, but I think printing the string is still helpful in any case.


Actually, we might just use gtk_tooltip_set_text instead of _set_markup in https://git.gnome.org/browse/gtk+/tree/gtk/gtklabel.c#n6855, since the link title can never contain markup on its own?  Or is that wanted so you can set title="<b>bold text</b>"?
Comment 3 Matthias Clasen 2015-07-28 11:02:40 UTC
The only thing I'm slightly worried about with the patch is that the string might not even be valid utf8, but maybe thats unfounded.
Comment 4 Timm Bäder 2015-07-29 09:53:31 UTC
IIRC invalid utf8 will be printed to the console just fine? I don't know if there's another warning for it but if not, printing the text would be helpful as well imo.

I just checked that using gtk_tooltip_set_text instead of _set_markup fixes the double-escape problem, but it breaks existing users that double-escaped their stuff of course :/
Comment 5 Matthias Clasen 2015-08-02 17:18:05 UTC
Review of attachment 308212 [details] [review]:

lets go with this, then
Comment 6 Timm Bäder 2015-08-03 09:32:36 UTC
Pushed as 61ba7adfc8f1b3ec9ea8deb25d63ca5898f6559c. Thanks!