SVG inlining code needs to escape `#` characters
This is in the context of librsvg#377 (closed):
GTK's code for icon themes takes the actual SVG data for an icon, and wraps it with extra styling information by generating the following data:
<svg ...> <style> ... extra styling here ... </style> <xi:include href="... original SVG encoded as a data: URL ..."/> </svg>
The master branch of librsvg replaced the C code that parsed
data: URLs in a rather loose way, with the data-url Rust crate that does this in a stricter fashion.
GTK creates the data: URL by concatenating these:
- The result of
g_markup_escape_text()on the original icon's SVG data.
However, per the data: URL spec, this generates an incorrect data: URL when the original SVG data has a
# in it, for example, in a
color="#000" attribute. The data: URL decoder thinks that everything past the
# is the URL's fragment identifier, and ignores it (data: URLs cannot have fragment identifiers).
GTK needs to escape
%23 while building the data: URL. (And librsvg needs to handle faulty
xi:include content properly, but that's librsvg#377 (closed).)
Addendum: the "wrap an icon's SVG" code is duplicated among
encodesymbolic.c, but the wrapper is slightly different in each. I don't know if they need to be the same; both do need to be fixed to escape