@@ -501,36 +501,31 @@ namespace Sass {
501501 return p;
502502 }
503503
504- Arguments* Parser::parse_arguments (bool has_url )
504+ Arguments* Parser::parse_arguments ()
505505 {
506506 std::string name (lexed);
507507 Position position = after_token;
508508 Arguments* args = SASS_MEMORY_NEW (ctx.mem , Arguments, pstate);
509509 if (lex_css< exactly<' (' > >()) {
510510 // if there's anything there at all
511511 if (!peek_css< exactly<' )' > >()) {
512- do (*args) << parse_argument (has_url );
512+ do (*args) << parse_argument ();
513513 while (lex_css< exactly<' ,' > >());
514514 }
515515 if (!lex_css< exactly<' )' > >()) error (" expected a variable name (e.g. $x) or ')' for the parameter list for " + name, position);
516516 }
517517 return args;
518518 }
519519
520- Argument* Parser::parse_argument (bool has_url )
520+ Argument* Parser::parse_argument ()
521521 {
522522 if (peek_css< sequence < exactly< hash_lbrace >, exactly< rbrace > > >()) {
523523 position += 2 ;
524524 css_error (" Invalid CSS" , " after " , " : expected expression (e.g. 1px, bold), was " );
525525 }
526526
527527 Argument* arg;
528- // some urls can look like line comments (parse literally - chunk would not work)
529- if (has_url && lex< sequence < uri_value, lookahead < loosely<' )' > > > >(false )) {
530- String* the_url = parse_interpolated_chunk (lexed);
531- arg = SASS_MEMORY_NEW (ctx.mem , Argument, the_url->pstate (), the_url);
532- }
533- else if (peek_css< sequence < variable, optional_css_comments, exactly<' :' > > >()) {
528+ if (peek_css< sequence < variable, optional_css_comments, exactly<' :' > > >()) {
534529 lex_css< variable >();
535530 std::string name (Util::normalize_underscores (lexed));
536531 ParserState p = pstate;
@@ -1410,6 +1405,9 @@ namespace Sass {
14101405 }
14111406 return string;
14121407 }
1408+ else if (peek< sequence< uri_prefix, W, real_uri_value > >()) {
1409+ return parse_url_function_string ();
1410+ }
14131411 else if (peek< re_functional >()) {
14141412 return parse_function_call ();
14151413 }
@@ -1790,14 +1788,39 @@ namespace Sass {
17901788 return SASS_MEMORY_NEW (ctx.mem , Function_Call, call_pos, name, args);
17911789 }
17921790
1791+ String* Parser::parse_url_function_string ()
1792+ {
1793+ const char * p = position;
1794+
1795+ lex< uri_prefix >();
1796+ std::string prefix = lexed;
1797+
1798+ lex< real_uri_value >(false );
1799+ std::string uri = lexed;
1800+
1801+ if (peek< exactly< hash_lbrace > >()) {
1802+ const char * pp = position;
1803+ // TODO: error checking for unclosed interpolants
1804+ while (peek< exactly< hash_lbrace > >(pp)) {
1805+ pp = sequence< interpolant, real_uri_value >(pp);
1806+ }
1807+ position = peek< real_uri_suffix >(pp);
1808+ return parse_interpolated_chunk (Token (p, position));
1809+ } else {
1810+ lex< real_uri_suffix >();
1811+ std::string res = prefix + Util::rtrim (uri) + lexed.to_string ();
1812+ return SASS_MEMORY_NEW (ctx.mem , String_Constant, pstate, res);
1813+ }
1814+
1815+ }
1816+
17931817 Function_Call* Parser::parse_function_call ()
17941818 {
17951819 lex< identifier >();
17961820 std::string name (lexed);
17971821
17981822 ParserState call_pos = pstate;
1799- bool expect_url = name == " url" || name == " url-prefix" ;
1800- Arguments* args = parse_arguments (expect_url);
1823+ Arguments* args = parse_arguments ();
18011824 return SASS_MEMORY_NEW (ctx.mem , Function_Call, call_pos, name, args);
18021825 }
18031826
0 commit comments