GNOME Bugzilla – Bug 396311
& in attributes in .glade files load as & instead of &
Last modified: 2007-01-21 06:18:02 UTC
Please describe the problem: libxml2 returns & in attributes as & instead of & Steps to reproduce: 1. Make a button whose "Name" attribute contains a & - OR - put a & in "Comments for translators" 2. Click save 3. Notice how saved .glade file is ok 4. Load the file Actual results: & has changed to & in the gui Expected results: & should remain & after load Does this happen every time? yes Other information: This is NOT a duplicate of Bug #360586. That bug is related to saving, this is related to loading. The actual problem is in the usage of the sax parser in the libxml2 library, and it has been reported as a bug multiple times, for example Bug #172638. There you see it's actually expected to behaviour, which can be changed to work as glade wants it simply by calling xmlSubstituteEntitiesDefault(1); before starting the sax parsing. I have tested this and it works fine. I'll attach a patch which simply adds the abovementioned call to the two places where the sax parsing occurs.
Created attachment 80215 [details] [review] Fixes the problem
Created attachment 80226 [details] [review] Fixes the problem, second attempt After sleeping overnight, I realized the same problem exists in libglade as well so I filed bug #396372 as well. While making a patch for libglade I also realized that my patch didn't restore the original state and thus if glade3 or some glade3 plugin would use libxml2 for anything else, the behaviour would be different. So, I attached a new patch which restores the original state afterwards. I have tested it to work just as well as the old one.
Ok thanks I'm committing this. Please in the future generate your patch with 'diff -up' (the -p option makes it easier to review). If you want to comment on this bug with your name, I'll put it in the ChangeLog.