Skip to content

Commit 5ae2e81

Browse files
committed
Disallow non-string argument to quote
Tests: sass/sass-spec#1380 Fixes #2811
1 parent 9740de6 commit 5ae2e81

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

src/fn_strings.cpp

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -65,20 +65,14 @@ namespace Sass {
6565
Signature quote_sig = "quote($string)";
6666
BUILT_IN(sass_quote)
6767
{
68-
AST_Node_Obj arg = env["$string"];
69-
// only set quote mark to true if already a string
70-
if (String_Quoted* qstr = Cast<String_Quoted>(arg)) {
71-
qstr->quote_mark('*');
72-
return qstr;
73-
}
74-
// all other nodes must be converted to a string node
75-
std::string str(quote(arg->to_string(ctx.c_options), '"'));
76-
String_Quoted* result = SASS_MEMORY_NEW(String_Quoted, pstate, str);
68+
const String_Constant* s = ARG("$string", String_Constant);
69+
String_Quoted *result = SASS_MEMORY_NEW(
70+
String_Quoted, pstate, s->value(),
71+
/*q=*/'\0', /*keep_utf8_escapes=*/false, /*skip_unquoting=*/true);
7772
result->quote_mark('*');
7873
return result;
7974
}
8075

81-
8276
Signature str_length_sig = "str-length($string)";
8377
BUILT_IN(str_length)
8478
{

0 commit comments

Comments
 (0)