From 44e7a9ef0705ab71a70e0ef3457db68827ec7759 Mon Sep 17 00:00:00 2001 From: Nick Schonning Date: Wed, 17 Jul 2019 22:03:24 -0400 Subject: [PATCH] fix: non-integers passed to str-slice See https://github.com/sass/sass-spec/pull/1443 Closes #2922 --- src/fn_strings.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/fn_strings.cpp b/src/fn_strings.cpp index b09fce9a6..c5cdbde2a 100644 --- a/src/fn_strings.cpp +++ b/src/fn_strings.cpp @@ -163,6 +163,11 @@ namespace Sass { String_Constant* s = ARG("$string", String_Constant); double start_at = ARGVAL("$start-at"); double end_at = ARGVAL("$end-at"); + + if (start_at != (int)start_at) { + error("$start-at: " + std::to_string(start_at) + " is not an int", pstate, traces); + } + String_Quoted* ss = Cast(s); std::string str(s->value()); @@ -173,6 +178,10 @@ namespace Sass { end_at = -1; } + if (end_at != (int)end_at) { + error("$end-at: " + std::to_string(end_at) + " is not an int", pstate, traces); + } + if (end_at == 0 || (end_at + size) < 0) { if (ss && ss->quote_mark()) newstr = quote(""); return SASS_MEMORY_NEW(String_Quoted, pstate, newstr);