diff --git a/src/prelexer.cpp b/src/prelexer.cpp index 86cc335d9..fe999b5ca 100644 --- a/src/prelexer.cpp +++ b/src/prelexer.cpp @@ -70,7 +70,15 @@ namespace Sass { { return sequence< exactly<'\\'>, - any_char + alternatives < + minmax_range< + 3, 3, xdigit + >, + any_char + >, + optional < + exactly <' '> + > >(src); } @@ -960,5 +968,19 @@ namespace Sass { return got ? pos : 0; } + template + const char* minmax_range(const char* src) + { + size_t got = 0; + const char* pos = src; + while (got < max) { + if (!mx(pos)) break; + ++ pos; ++ got; + } + if (got < min) return 0; + if (got > min) return 0; + return pos; + } + } } diff --git a/src/prelexer.hpp b/src/prelexer.hpp index de4a89481..867a89e53 100644 --- a/src/prelexer.hpp +++ b/src/prelexer.hpp @@ -393,6 +393,9 @@ namespace Sass { template const char* padded_token(const char* src); + template + const char* minmax_range(const char* src); + } } diff --git a/src/util.cpp b/src/util.cpp index a0ba1b541..9532462e8 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -363,6 +363,8 @@ namespace Sass { // ToDo: Maybe we could do this without creating a substring uint32_t cp = strtol(s.substr (i + 1, len - 1).c_str(), nullptr, 16); + if (s[i + len] == ' ') ++ len; + // assert invalid code points if (cp == 0) cp = 0xFFFD; // replace bell character