Skip to content

Commit dfbdf67

Browse files
authored
Merge pull request #2241 from xzyfer/fix/issue-2240
Fix incorrect str-slice behaviour
2 parents 5b92405 + 1fc3d97 commit dfbdf67

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/functions.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1020,16 +1020,19 @@ namespace Sass {
10201020
std::string str = unquote(s->value());
10211021

10221022
size_t size = utf8::distance(str.begin(), str.end());
1023+
10231024
if (end_at <= size * -1.0 && size > 1) {
1024-
end_at += size;
1025-
if (end_at == 0) end_at = 1;
1025+
end_at = 0;
10261026
}
10271027
if (end_at < 0) {
10281028
end_at += size + 1;
10291029
if (end_at == 0) end_at = 1;
10301030
}
10311031
if (end_at > size) { end_at = (double)size; }
1032-
if (start_at < 0) { start_at += size + 1; }
1032+
if (start_at < 0) {
1033+
start_at += size + 1;
1034+
if (start_at < 0) start_at = 0;
1035+
}
10331036
else if (start_at == 0) { ++ start_at; }
10341037

10351038
if (start_at <= end_at)

0 commit comments

Comments
 (0)