@@ -861,7 +861,7 @@ namespace Sass {
861861 }
862862 }
863863
864- std::string Eval::interpolation (Expression* s) {
864+ std::string Eval::interpolation (Expression* s, bool into_quotes ) {
865865 Env* env = environment ();
866866 if (String_Quoted* str_quoted = dynamic_cast <String_Quoted*>(s)) {
867867 if (str_quoted->quote_mark ()) {
@@ -874,6 +874,7 @@ namespace Sass {
874874 return evacuate_escapes (str_quoted->value ());
875875 }
876876 } else if (String_Constant* str_constant = dynamic_cast <String_Constant*>(s)) {
877+ if (into_quotes && !str_constant->is_interpolant ()) return str_constant->value ();
877878 return evacuate_escapes (str_constant->value ());
878879 } else if (dynamic_cast <Parent_Selector*>(s)) {
879880 To_String to_string (&ctx);
@@ -936,7 +937,17 @@ namespace Sass {
936937 Expression* Eval::operator ()(String_Schema* s)
937938 {
938939 std::string acc;
939- for (size_t i = 0 , L = s->length (); i < L; ++i) {
940+ bool into_quotes = false ;
941+ size_t L = s->length ();
942+ if (L > 1 ) {
943+ if (String_Constant* l = dynamic_cast <String_Constant*>((*s)[0 ])) {
944+ if (String_Constant* r = dynamic_cast <String_Constant*>((*s)[L - 1 ])) {
945+ if (l->value ()[0 ] == ' "' && r->value ()[r->value ().size () - 1 ] == ' "' ) into_quotes = true ;
946+ if (l->value ()[0 ] == ' \' ' && r->value ()[r->value ().size () - 1 ] == ' \' ' ) into_quotes = true ;
947+ }
948+ }
949+ }
950+ for (size_t i = 0 ; i < L; ++i) {
940951 // really a very special fix, but this is the logic I got from
941952 // analyzing the ruby sass behavior and it actually seems to work
942953 // https://github.com/sass/libsass/issues/1333
@@ -946,13 +957,13 @@ namespace Sass {
946957 if (sq->is_delayed () && ! s->has_interpolants ()) {
947958 acc += string_escape (quote (sq->value (), sq->quote_mark ()));
948959 } else {
949- acc += interpolation ((*s)[i]);
960+ acc += interpolation ((*s)[i], into_quotes );
950961 }
951962 } else if (ex) {
952- acc += interpolation ((*s)[i]);
963+ acc += interpolation ((*s)[i], into_quotes );
953964 }
954965 } else if ((*s)[i]) {
955- acc += interpolation ((*s)[i]);
966+ acc += interpolation ((*s)[i], into_quotes );
956967 }
957968 }
958969 String_Quoted* str = SASS_MEMORY_NEW (ctx.mem , String_Quoted, s->pstate (), acc);
@@ -1316,12 +1327,17 @@ namespace Sass {
13161327 if (ltype == Expression::NULL_VAL) error (" invalid null operation: \" null plus " +quote (unquote (rstr), ' "' )+" \" ." , lhs.pstate ());
13171328 if (rtype == Expression::NULL_VAL) error (" invalid null operation: \" " +quote (unquote (lstr), ' "' )+" plus null\" ." , rhs.pstate ());
13181329
1319- String_Constant* str = (ltype == Expression::STRING || sep == " " ) &&
1320- (sep != " /" || !rqstr || !rqstr->quote_mark ())
1321- ? SASS_MEMORY_NEW (mem, String_Quoted, lhs.pstate (), (lstr) + sep + (rstr))
1322- : SASS_MEMORY_NEW (mem, String_Constant, lhs.pstate (), (lstr) + sep + quote (rstr));
1323- str->quote_mark (0 );
1324- return str;
1330+ if ( (ltype == Expression::STRING || sep == " " ) &&
1331+ (sep != " /" || !rqstr || !rqstr->quote_mark ())
1332+ ) {
1333+ char quote_mark = 0 ;
1334+ std::string unq (unquote (lstr + sep + rstr, "e_mark, true ));
1335+ if (quote_mark && quote_mark != ' *' ) {
1336+ return SASS_MEMORY_NEW (mem, String_Constant, lhs.pstate (), quote_mark + unq + quote_mark);
1337+ }
1338+ return SASS_MEMORY_NEW (mem, String_Quoted, lhs.pstate (), lstr + sep + rstr);
1339+ }
1340+ return SASS_MEMORY_NEW (mem, String_Constant, lhs.pstate (), (lstr) + sep + quote (rstr));
13251341 }
13261342
13271343 Expression* cval_to_astnode (Memory_Manager<AST_Node>& mem, union Sass_Value* v, Context& ctx, Backtrace* backtrace, ParserState pstate)
0 commit comments