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

Incorrect parsing of consecutive quoted strings, unquoted strings and interpolations. #1413

Closed
andrew-skybound opened this issue Jul 28, 2015 · 5 comments

Comments

@andrew-skybound
Copy link

When no space is present between consecutive quoted strings, unquoted strings and interpolations, Libsass doesn't parse the sequence the same as Ruby sass does.

From what I can tell, Ruby always generates a single string when the sequence contains an interpolation, and makes a list otherwise. However, it inserts spaces into the generated string BETWEEN each quoted and unquoted string.

Here are some examples to clear things up. Note that I've used single quotes in the input, which Ruby always converts to double quotes in the output, but Libsass does not in some cases. Maybe this should be a separate issue, I'm not sure.

Test 1 (sequences with ONLY strings or ONLY interpolation):

foo: A'A';
foo: 'A'B;
foo: A'B'C;
foo: 'A'B'C';
foo: A#{A};
foo: #{A}B;
foo: A#{B}C;
foo: #{A}B#{C};

Test 1 Output (Libsass and Ruby are identical here, including quotes):

foo: A "A";
foo: "A" B;
foo: A "B" C;
foo: "A" B "C";
foo: AA;
foo: AB;
foo: ABC;
foo: ABC;

type-of() for the first 4 declarations above is "list"; type-of() for the second 4 is "string".

Test 2 (sequences with both strings and interpolation):

foo: 'A'#{B};
foo: #{A}'B';
foo: 'A'#{B}'C';
foo: #{A}'B'#{C};
foo: A#{B}'C';
foo: 'A'#{B}C;
foo: #{A}B'C';
foo: 'A'#{B}C'D';
foo: 'A'B#{C}D'E';
foo: A'B'#{C}D'E';

Test 2 Output (Ruby):

foo: "A"B;
foo: A"B";
foo: "A"B"C";
foo: A"B"C;
foo: AB"C";
foo: "A"BC;
foo: AB "C";
foo: "A"BC "D";
foo: "A" BCD "E";
foo: A "B"CD "E";

Note that type-of() for all declarations above returns "string" in Ruby. So the spaces would appear to be spaces in a single unquoted string.

Test 2 Output (Libsass):

foo: 'A'B;
foo: A 'B';       // incorrect, type-of() == list, length() == 2
foo: 'A'B'C';
foo: A 'B'C;      // incorrect, type-of() == list, length() == 2
foo: AB 'C';      // incorrect, type-of() == list, length() == 2
foo: 'A'BC;
foo: AB 'C';      // correct, BUT type-of() == list, length() == 2
foo: 'A'BC'D';    // incorrect, type-of() == string, but spaces are missing
foo: 'A'BCD'E';   // incorrect, type-of() == string, but spaces are missing
foo: A'B'CD'E';   // incorrect, type-of() == string, but spaces are missing
@xzyfer
Copy link
Contributor

xzyfer commented Jul 29, 2015

@andrew-skybound I'm having trouble following your issue. Please produce copy-pastable code that show the difference between Ruby Sass and LibSass so we can plainly see the difference and debug it.

@andrew-skybound
Copy link
Author

Input:

div {
    foo: 'A'#{B};
    foo: #{A}'B';
    foo: 'A'#{B}'C';
    foo: #{A}'B'#{C};
    foo: A#{B}'C';
    foo: 'A'#{B}C;
    foo: #{A}B'C';
    foo: 'A'#{B}C'D';
    foo: 'A'B#{C}D'E';
    foo: A'B'#{C}D'E';
}

div {
    foo: type-of('A'#{B});
    foo: type-of(#{A}'B');
    foo: type-of('A'#{B}'C');
    foo: type-of(#{A}'B'#{C});
    foo: type-of(A#{B}'C');
    foo: type-of('A'#{B}C);
    foo: type-of(#{A}B'C');
    foo: type-of('A'#{B}C'D');
    foo: type-of('A'B#{C}D'E');
    foo: type-of(A'B'#{C}D'E');
}

div {
    foo: length('A'#{B});
    foo: length(#{A}'B');
    foo: length('A'#{B}'C');
    foo: length(#{A}'B'#{C});
    foo: length(A#{B}'C');
    foo: length('A'#{B}C);
    foo: length(#{A}B'C');
    foo: length('A'#{B}C'D');
    foo: length('A'B#{C}D'E');
    foo: length(A'B'#{C}D'E');
}

Ruby SASS Output:

div {
  foo: "A"B;
  foo: A"B";
  foo: "A"B"C";
  foo: A"B"C;
  foo: AB"C";
  foo: "A"BC;
  foo: AB "C";
  foo: "A"BC "D";
  foo: "A" BCD "E";
  foo: A "B"CD "E";
}

div {
  foo: string;
  foo: string;
  foo: string;
  foo: string;
  foo: string;
  foo: string;
  foo: string;
  foo: string;
  foo: string;
  foo: string;
}

div {
  foo: 1;
  foo: 1;
  foo: 1;
  foo: 1;
  foo: 1;
  foo: 1;
  foo: 1;
  foo: 1;
  foo: 1;
  foo: 1;
}

Libsass Output:

div {
  foo: 'A'B;
  foo: A'B';
  foo: 'A'B'C';
  foo: A'B'C;
  foo: AB'C';
  foo: 'A'BC;
  foo: AB'C';
  foo: 'A'BC'D';
  foo: 'A'BCD'E';
  foo: A'B'CD'E';
}

div {
  foo: string;
  foo: list;
  foo: string;
  foo: list;
  foo: list;
  foo: string;
  foo: list;
  foo: string;
  foo: string;
  foo: string;
}

div {
  foo: 1;
  foo: 2;
  foo: 1;
  foo: 2;
  foo: 2;
  foo: 1;
  foo: 2;
  foo: 1;
  foo: 1;
  foo: 1;
}

@xzyfer
Copy link
Contributor

xzyfer commented Aug 24, 2015

@mgreter which PR addresses this?

@mgreter
Copy link
Contributor

mgreter commented Aug 24, 2015

I guess #1475

@xzyfer
Copy link
Contributor

xzyfer commented Aug 24, 2015

Confirmed #1475 fixes this.

@xzyfer xzyfer mentioned this issue Aug 24, 2015
20 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants