Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

str-slice with $end-at should never return a value #762

Merged
merged 1 commit into from
Dec 26, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -923,7 +923,9 @@ namespace Sass {
size_t start = UTF_8::offset_at_position(str, UTF_8::normalize_index(n->value(), UTF_8::code_point_count(str)));
size_t end = UTF_8::offset_at_position(str, UTF_8::normalize_index(m->value(), UTF_8::code_point_count(str)));

if(start == end) {
// `str-slice` should always return an empty string when $end-at == 0
// `normalize_index` normalizes 1 -> 0 so we need to check the original value
if(start == end && m->value() > 0) {
newstr = str.substr(start, 1);
} else if(end > start) {
newstr = str.substr(start, end - start + UTF_8::code_point_size_at_offset(str, end));
Expand Down