From 27ef31233ce616a807593af1c7e1eda2ebab0703 Mon Sep 17 00:00:00 2001 From: Adeel Date: Wed, 30 Dec 2015 17:13:41 +0200 Subject: [PATCH] util: Adds CRLF awareness to quote(). Input: ```scss @import url("a b"); ``` Output on Windows: ```css "@import url(\"a\r\a b\")"; ``` Output on Unix (alinged with Ruby Sass, hence the expected output): ```css "@import url(\"a\a b\")"; ``` See: https://github.com/sass/libsass/issues/1096#issuecomment-167531680 for details. --- src/util.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/util.cpp b/src/util.cpp index afa2edf5b9..6d9157ca0a 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -488,6 +488,12 @@ namespace Sass { int cp = utf8::next(it, end); + // in case of \r, check if the next in sequence + // is \n and then advance the iterator. + if (cp == '\r' && it < end && utf8::peek_next(it, end) == '\n') { + cp = utf8::next(it, end); + } + if (cp == '\n') { quoted.push_back('\\'); quoted.push_back('a');