diff options
author | Menner <mik@gmx.org> | 2015-07-02 19:02:51 -0500 |
---|---|---|
committer | Federico Mena Quintero <federico@gnome.org> | 2015-07-02 19:03:42 -0500 |
commit | 9c718ff7ac9a3f1aa37d847584a07b13ed1769f0 (patch) | |
tree | d9ac6101c1f8bace358cbb40713561eb4734aec7 | |
parent | fdd275975abc3085340db465e9cc0a605b55a1b1 (diff) | |
download | librsvg-9c718ff7ac9a3f1aa37d847584a07b13ed1769f0.tar.gz |
bgo#739329 - Remove single quotes around font-family names before passing them to Pango
If you have an SVG with
<text style="font-family: 'New Century Schoolbook';"> ... </text>
our CSS-parsing code simply passes the singly-quoted string to Pango. In turn,
Pango doesn't like the quotes because they are not part of the font's name.
This is a simple patch to remove single quotes from *all* style attributes, not
just strings (which is where the CSS spec allows them). We need a real CSS
parser, not something built out of g_strsplit().
-rw-r--r-- | rsvg-styles.c | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/rsvg-styles.c b/rsvg-styles.c index 1247fa4a..0b7baf51 100644 --- a/rsvg-styles.c +++ b/rsvg-styles.c @@ -970,12 +970,28 @@ rsvg_parse_style (RsvgHandle * ctx, RsvgState * state, const char *str) if (g_strv_length (values) == 2) { gboolean important; gchar *style_value = NULL; - if (parse_style_value (values[1], &style_value, &important)) + gchar *first_value = values[0]; + gchar *second_value = values[1]; + gchar **split_list; + + /* Just remove single quotes in a trivial way. No handling for any + * special character inside the quotes is done. This relates + * especially to font-family names but cases with special characters + * are rare. + * + * We need a real CSS parser, sigh. + */ + split_list = g_strsplit (second_value, "'", -1); + second_value = g_strjoinv(NULL, split_list); + g_strfreev(split_list); + + if (parse_style_value (second_value, &style_value, &important)) rsvg_parse_style_pair (ctx, state, - g_strstrip (values[0]), + g_strstrip (first_value), style_value, important); g_free (style_value); + g_free (second_value); } g_strfreev (values); } |