Skip to content

Commit bf138cf

Browse files
committed
Improve IE expression string tokenizing
1 parent f3d2ead commit bf138cf

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

debugger.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,7 @@ inline void debug_ast(AST_Node* node, string ind = "", Env* env = 0)
489489
cerr << " [" << prettyprint(expression->value()) << "]" <<
490490
(expression->is_delayed() ? " {delayed}" : "") <<
491491
(expression->sass_fix_1291() ? " {sass_fix_1291}" : "") <<
492+
(expression->quote_mark() != 0 ? " {qm:" + string(1, expression->quote_mark()) + "}" : "") <<
492493
" <" << prettyprint(expression->pstate().token.ws_before()) << ">" << endl;
493494
} else if (dynamic_cast<String_Schema*>(node)) {
494495
String_Schema* expression = dynamic_cast<String_Schema*>(node);

parser.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1415,6 +1415,7 @@ namespace Sass {
14151415
Token str(lexed);
14161416
const char* i = str.begin;
14171417
// see if there any interpolants
1418+
const char* q;
14181419
const char* p = find_first_in_interval< exactly<hash_lbrace> >(str.begin, str.end);
14191420
if (!p) {
14201421
String_Constant* str_node = new (ctx.mem) String_Constant(pstate, normalize_wspace(string(str.begin, str.end)));
@@ -1424,8 +1425,16 @@ namespace Sass {
14241425

14251426
String_Schema* schema = new (ctx.mem) String_Schema(pstate);
14261427
while (i < str.end) {
1428+
q = find_first_in_interval< alternatives< exactly<'"'>, exactly<'\''> > >(i, str.end);
14271429
p = find_first_in_interval< exactly<hash_lbrace> >(i, str.end);
1428-
if (p) {
1430+
if (q && (!p || p > q)) {
1431+
if (i < q) {
1432+
(*schema) << new (ctx.mem) String_Constant(pstate, string(i, q)); // accumulate the preceding segment if it's nonempty
1433+
}
1434+
(*schema) << new (ctx.mem) String_Constant(pstate, string(q, q+1)); // capture the quote mark separately
1435+
i = q+1;
1436+
}
1437+
else if (p) {
14291438
if (i < p) {
14301439
(*schema) << new (ctx.mem) String_Constant(pstate, string(i, p)); // accumulate the preceding segment if it's nonempty
14311440
}

0 commit comments

Comments
 (0)