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

CSS tokenizer does not tokenize class names correctly when they contain the string NEW #2246

Merged
merged 1 commit into from
Dec 10, 2018

Conversation

jrfnl
Copy link
Contributor

@jrfnl jrfnl commented Nov 27, 2018

Came across this while working on some of the Squiz CSS sniffs.

This code sample:

.HelpWidgetType-new-bug-title {}

Was tokenized as:

0 :: L001 :: C1 :: T_OPEN_TAG :: (0) ::
1 :: L001 :: C1 :: T_STRING_CONCAT :: (1) :: .
2 :: L001 :: C2 :: T_STRING :: (14) :: HelpWidgetType
3 :: L001 :: C16 :: T_MINUS :: (1) :: -
4 :: L001 :: C17 :: T_NEW :: (3) :: new
5 :: L001 :: C20 :: T_STRING :: (10) :: -bug-title
6 :: L001 :: C30 :: T_WHITESPACE :: (1) ::
7 :: L001 :: C31 :: T_OPEN_CURLY_BRACKET :: (1) :: {
8 :: L001 :: C32 :: T_CLOSE_CURLY_BRACKET :: (1) :: }

...while I would expect the class identifier to be tokenized as one T_STRING HelpWidgetType-new-bug-title instead.

This commit fixes that and the code sample is now tokenized as:

0 :: L001 :: C1 :: T_OPEN_TAG :: (0) ::
1 :: L001 :: C1 :: T_STRING_CONCAT :: (1) :: .
2 :: L001 :: C2 :: T_STRING :: (28) :: HelpWidgetType-new-bug-title
3 :: L001 :: C30 :: T_WHITESPACE :: (1) ::
4 :: L001 :: C31 :: T_OPEN_CURLY_BRACKET :: (1) :: {
5 :: L001 :: C32 :: T_CLOSE_CURLY_BRACKET :: (1) :: }

No additional unit tests needed as the existing unit test in the Squiz/Tests/CSS/SemicolonspacingUnitTest.css file already covers this (as that's how I came across it).

Came across this while working on some of the Squiz CSS sniffs.

This code sample:
```css
.HelpWidgetType-new-bug-title {}
```

Was tokenized as:
```
0 :: L001 :: C1 :: T_OPEN_TAG :: (0) ::
1 :: L001 :: C1 :: T_STRING_CONCAT :: (1) :: .
2 :: L001 :: C2 :: T_STRING :: (14) :: HelpWidgetType
3 :: L001 :: C16 :: T_MINUS :: (1) :: -
4 :: L001 :: C17 :: T_NEW :: (3) :: new
5 :: L001 :: C20 :: T_STRING :: (10) :: -bug-title
6 :: L001 :: C30 :: T_WHITESPACE :: (1) ::
7 :: L001 :: C31 :: T_OPEN_CURLY_BRACKET :: (1) :: {
8 :: L001 :: C32 :: T_CLOSE_CURLY_BRACKET :: (1) :: }
```

...while I would expect the class identifier to be tokenized as one T_STRING `HelpWidgetType-new-bug-title` instead.

This commit fixes that and the code sample is now tokenized as:
```
0 :: L001 :: C1 :: T_OPEN_TAG :: (0) ::
1 :: L001 :: C1 :: T_STRING_CONCAT :: (1) :: .
2 :: L001 :: C2 :: T_STRING :: (28) :: HelpWidgetType-new-bug-title
3 :: L001 :: C30 :: T_WHITESPACE :: (1) ::
4 :: L001 :: C31 :: T_OPEN_CURLY_BRACKET :: (1) :: {
5 :: L001 :: C32 :: T_CLOSE_CURLY_BRACKET :: (1) :: }
```

No additional unit tests needed as the existing unit test in the `Squiz/Tests/CSS/SemicolonspacingUnitTest.css` file already covers this (as that's how I came across it).
@gsherwood gsherwood added this to the 3.4.0 milestone Dec 6, 2018
@gsherwood gsherwood changed the title CSS tokenizer: bug fix CSS tokenizer does not tokenize class names correctly when they contain the string NEW Dec 10, 2018
@gsherwood gsherwood merged commit ad27eb4 into squizlabs:master Dec 10, 2018
gsherwood added a commit that referenced this pull request Dec 10, 2018
@gsherwood
Copy link
Member

Thanks

@jrfnl jrfnl deleted the feature/css-tokenizer-bugfix branch December 10, 2018 00:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants