@@ -519,6 +519,10 @@ namespace Sass {
519
519
520
520
Argument* Parser::parse_argument (bool has_url)
521
521
{
522
+ if (peek_css< sequence < exactly< hash_lbrace >, exactly< rbrace > > >()) {
523
+ position += 2 ;
524
+ css_error (" Invalid CSS" , " after " , " : expected expression (e.g. 1px, bold), was " );
525
+ }
522
526
523
527
Argument* arg;
524
528
// some urls can look like line comments (parse literally - chunk would not work)
@@ -1638,6 +1642,9 @@ namespace Sass {
1638
1642
// lex an interpolant /#{...}/
1639
1643
else if (lex< exactly < hash_lbrace > >()) {
1640
1644
// Try to lex static expression first
1645
+ if (peek< exactly< rbrace > >()) {
1646
+ css_error (" Invalid CSS" , " after " , " : expected expression (e.g. 1px, bold), was " );
1647
+ }
1641
1648
if (lex< re_static_expression >()) {
1642
1649
(*schema) << SASS_MEMORY_NEW (ctx.mem , String_Constant, pstate, lexed);
1643
1650
} else {
@@ -1720,7 +1727,7 @@ namespace Sass {
1720
1727
}
1721
1728
// we need to skip anything inside strings
1722
1729
// create a new target in parser/prelexer
1723
- if (peek < sequence < optional_spaces, exactly<rbrace> > >(p+2 )) { position = p+ 2 ;
1730
+ if (peek < sequence < optional_spaces, exactly<rbrace> > >(p+2 )) { position = p;
1724
1731
css_error (" Invalid CSS" , " after " , " : expected expression (e.g. 1px, bold), was " );
1725
1732
}
1726
1733
const char * j = skip_over_scopes< exactly<hash_lbrace>, exactly<rbrace> >(p+2 , id.end ); // find the closing brace
@@ -2432,7 +2439,7 @@ namespace Sass {
2432
2439
// print a css parsing error with actual context information from parsed source
2433
2440
void Parser::css_error (const std::string& msg, const std::string& prefix, const std::string& middle)
2434
2441
{
2435
- int max_len = 14 ;
2442
+ int max_len = 18 ;
2436
2443
const char * pos = peek < optional_spaces >();
2437
2444
2438
2445
const char * last_pos (pos - 1 );
@@ -2443,7 +2450,7 @@ namespace Sass {
2443
2450
const char * pos_left (last_pos + 1 );
2444
2451
const char * end_left (last_pos + 1 );
2445
2452
while (pos_left > source) {
2446
- if (end_left - pos_left > max_len) {
2453
+ if (end_left - pos_left >= max_len) {
2447
2454
ellipsis_left = true ;
2448
2455
break ;
2449
2456
}
@@ -2473,8 +2480,8 @@ namespace Sass {
2473
2480
2474
2481
std::string left (pos_left, end_left);
2475
2482
std::string right (pos_right, end_right);
2476
- if (ellipsis_left) left = ellipsis + left;
2477
- if (ellipsis_right) right = right + ellipsis;
2483
+ if (ellipsis_left) left = ellipsis + left. substr (left. size () - 15 ) ;
2484
+ if (ellipsis_right) right = right. substr (right. size () - 15 ) + ellipsis;
2478
2485
// now pass new message to the more generic error function
2479
2486
error (msg + prefix + quote (left) + middle + quote (right), pstate);
2480
2487
}
0 commit comments