Skip to content

Commit

Permalink
Fix str-slice function with negative size
Browse files Browse the repository at this point in the history
Fixes #2132
  • Loading branch information
Ian Mitchell authored and mgreter committed Aug 3, 2016
1 parent 55c0858 commit 7c7b112
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1020,11 +1020,12 @@ namespace Sass {
std::string str = unquote(s->value());

size_t size = utf8::distance(str.begin(), str.end());
if (end_at <= size * -1.0) { end_at += size; }
if (end_at <= size * -1.0 && size > 1) { end_at += size; }
if (end_at < 0) { end_at += size + 1; }
if (end_at > size) { end_at = (double)size; }
if (start_at < 0) { start_at += size + 1; }
else if (start_at == 0) { ++ start_at; }
if (end_at == 0) end_at = 1;;

if (start_at <= end_at)
{
Expand Down

0 comments on commit 7c7b112

Please sign in to comment.