From e2cfd5ba144138fe02dcd59966d81781e4d6b55d Mon Sep 17 00:00:00 2001 From: Marcel Greter Date: Wed, 6 Jan 2016 04:42:13 +0100 Subject: [PATCH] Error on invalid parent selector placements --- src/parser.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/parser.cpp b/src/parser.cpp index 3441674ca5..46cf89d799 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -732,6 +732,18 @@ namespace Sass { // this produces a linefeed!? seq->has_parent_reference(true); (*seq) << SASS_MEMORY_NEW(ctx.mem, Parent_Selector, pstate); + // parent selector only allowed at start + // upcoming sass may allow also trailing + if (seq->length() > 1) { + ParserState state(pstate); + Simple_Selector* cur = (*seq)[seq->length()-1]; + Simple_Selector* prev = (*seq)[seq->length()-2]; + std::string sel(prev->to_string(false, 5)); + std::string found(cur->to_string(false, 5)); + if (lex < identifier >()) { found += std::string(lexed); } + error("Invalid CSS after \"" + sel + "\": expected \"{\", was \"" + found + "\"\n\n" + "\"" + found + "\" may only be used at the beginning of a compound selector.", state); + } } // parse type selector else if (lex< re_type_selector >(false))