4
4
// FIXME: kill this ugliness when we have a proper CSS parser
5
gchar *extract_uri(gchar const *s)
6
// Functions as per 4.3.4 of CSS 2.1
7
// http://www.w3.org/TR/CSS21/syndata.html#uri
8
gchar *extract_uri( gchar const *s, gchar const** endptr )
7
14
gchar const *sb = s;
8
g_assert( strncmp(sb, "url", 3) == 0 );
15
if ( strlen(sb) < 4 || strncmp(sb, "url", 3) != 0 ) {
25
// This first whitespace technically is not allowed.
26
// Just left in for now for legacy behavior.
11
27
while ( ( *sb == ' ' ) ||
17
gchar const *se = sb + strlen(sb);
18
while ( ( se[-1] == ' ' ) ||
25
return g_strndup(sb, se - sb);
35
while ( ( *sb == ' ' ) ||
42
if ( (*sb == '\'' || *sb == '"') ) {
46
gchar const* se = sb + 1;
47
while ( *se && (*se != delim) ) {
51
// we found the delimiter
58
// back up for any trailing whitespace
60
while ( ( se[-1] == ' ' ) ||
66
result = g_strndup(sb, se - sb + 1);
68
gchar const* tail = se + 1;
69
while ( ( *tail == ' ' ) ||
78
result = g_strndup(sb, se - sb);