Skip to content

Commit b05e666

Browse files
committed
Merge pull request #1051 from mgreter/bugfix/url-trailing-spaces
Fix url parsing with trailing spaces in url
2 parents de362f2 + 51b0bf0 commit b05e666

File tree

3 files changed

+27
-12
lines changed

3 files changed

+27
-12
lines changed

constants.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ namespace Sass {
138138
extern const char arglist_name[] = "arglist";
139139

140140
// constants for uri parsing (RFC 3986 Appendix A.)
141-
extern const char uri_chars[] = ":/?!$%&#@[]{}'\"*+-._=";
141+
extern const char uri_chars[] = ":;/?!$%&#@[]{}'\"*+-.,_=";
142142

143143
// some specific constant character classes
144144
// they must be static to be useable by lexer

lexer.hpp

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -77,19 +77,19 @@ namespace Sass {
7777

7878
// Match a single character literal.
7979
// Regex equivalent: /(?:literal)/
80-
template <char pre>
80+
template <char chr>
8181
const char* exactly(const char* src) {
82-
return *src == pre ? src + 1 : 0;
82+
return *src == chr ? src + 1 : 0;
8383
}
8484

8585
// Match a string constant.
8686
// Regex equivalent: /[axy]/
87-
template <const char* prefix>
87+
template <const char* str>
8888
const char* exactly(const char* src) {
89-
if (prefix == 0) return 0;
90-
const char* pre = prefix;
89+
if (str == 0) return 0;
90+
const char* pre = str;
9191
if (src == 0) return 0;
92-
// there is a small chance that the search prefix
92+
// there is a small chance that the search string
9393
// is longer than the rest of the string to look at
9494
while (*pre && *src == *pre) {
9595
++src, ++pre;
@@ -117,9 +117,9 @@ namespace Sass {
117117

118118
// Match all except the supplied one.
119119
// Regex equivalent: /[^x]/
120-
template <const char c>
120+
template <const char chr>
121121
const char* any_char_but(const char* src) {
122-
return (*src && *src != c) ? src + 1 : 0;
122+
return (*src && *src != chr) ? src + 1 : 0;
123123
}
124124

125125
// Succeeds if the matcher fails.
@@ -210,14 +210,29 @@ namespace Sass {
210210

211211
// Match with word boundary rule.
212212
// Regex equivalent: /(?:$mx)\b/
213-
template <const char* mx>
213+
template <const char* str>
214214
const char* word(const char* src) {
215215
return sequence <
216-
exactly < mx >,
216+
exactly < str >,
217217
word_boundary
218218
>(src);
219219
}
220220

221+
template <char chr>
222+
const char* loosely(const char* src) {
223+
return sequence <
224+
optional_spaces,
225+
exactly < chr >
226+
>(src);
227+
}
228+
template <const char* str>
229+
const char* loosely(const char* src) {
230+
return sequence <
231+
optional_spaces,
232+
exactly < str >
233+
>(src);
234+
}
235+
221236
}
222237
}
223238

parser.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ namespace Sass {
382382

383383
Argument* arg;
384384
// some urls can look like line comments (parse literally - chunk would not work)
385-
if (has_url && lex< sequence < uri_value, lookahead < exactly<')'> > > >(false)) {
385+
if (has_url && lex< sequence < uri_value, lookahead < loosely<')'> > > >(false)) {
386386
String* the_url = parse_interpolated_chunk(lexed);
387387
arg = new (ctx.mem) Argument(the_url->pstate(), the_url);
388388
}

0 commit comments

Comments
 (0)