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

Crash on inline comments that contain single quotes #117

Closed
EvHaus opened this issue Sep 24, 2018 · 4 comments
Closed

Crash on inline comments that contain single quotes #117

EvHaus opened this issue Sep 24, 2018 · 4 comments

Comments

@EvHaus
Copy link

EvHaus commented Sep 24, 2018

  • Node Version: v10.11.0
  • NPM Version: 6.4.1
  • postcss Version: 7.0.2
  • postcss-less Version: 3.0.1

If you have a large amount of code to share which demonstrates the problem you're experiencing, please provide a link to your
repository rather than pasting code. Otherwise, please paste relevant short snippets below.

LESS

.someClass {
   // How's it going?
   color: red;
}

JavaScript

N/A

Errors

/Users/ev.haus/Git/aurora/node_modules/postcss/lib/lazy-result.js:248
        if (this.error) throw this.error;
                        ^
CssSyntaxError: /Users/ev.haus/Git/aurora/packages/aurora-ux/src/Button/Button.less:7:54: Unclosed string

  5 | 	box-shadow: none;
  6 | 	cursor: pointer;
> 7 | 	// How's it going?
    | 	                   ^
  8 | 	       color: red;
  9 | }

    at Input.error (/Users/ev.haus/Git/aurora/node_modules/postcss-less/node_modules/postcss/lib/input.es6:101:16)
    at error (/Users/ev.haus/Git/aurora/node_modules/postcss-less/node_modules/postcss/lib/tokenize.es6:41:17)
    at Object.unclosed [as nextToken] (/Users/ev.haus/Git/aurora/node_modules/postcss-less/node_modules/postcss/lib/tokenize.es6:178:15)
    at LessParser.isInlineComment (/Users/ev.haus/Git/aurora/node_modules/postcss-less/lib/nodes/inline-comment.js:12:32)
    at LessParser.other (/Users/ev.haus/Git/aurora/node_modules/postcss-less/lib/LessParser.js:57:36)
    at LessParser.other (/Users/ev.haus/Git/aurora/node_modules/postcss-less/node_modules/postcss/lib/parser.es6:56:16)
    at parse (/Users/ev.haus/Git/aurora/node_modules/postcss-less/lib/index.js:11:12)
    at parser (/Users/ev.haus/Git/aurora/packages/aurora-jasmine-runner/environ-jasmine.js:41:19)
    at new parser (/Users/ev.haus/Git/aurora/node_modules/postcss/lib/lazy-result.es6:42:24)
    at Processor.process (/Users/ev.haus/Git/aurora/node_modules/postcss/lib/processor.es6:95:16)
    at fetch (/Users/ev.haus/Git/aurora/node_modules/css-modules-require-hook/lib/index.js:99:29)
    at hook (/Users/ev.haus/Git/aurora/node_modules/css-modules-require-hook/lib/index.js:125:18)
    at Object.cssModulesHook [as .less] (/Users/ev.haus/Git/aurora/node_modules/css-modules-require-hook/lib/attachHook.js:16:20)
    at Module.load (internal/modules/cjs/loader.js:599:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
    at Function.Module._load (internal/modules/cjs/loader.js:530:3)
    at Module.require (internal/modules/cjs/loader.js:637:17)
    at require (internal/modules/cjs/helpers.js:20:18)
    at Object.<anonymous> (/Users/ev.haus/Git/aurora/packages/aurora-ux/src/Button/Button.js:8:1)
    at Module._compile (internal/modules/cjs/loader.js:689:30)
    at Module._compile (/Users/ev.haus/Git/aurora/node_modules/pirates/lib/index.js:83:24)
    at Module._extensions..js (internal/modules/cjs/loader.js:700:10)
    at Object.newLoader [as .js] (/Users/ev.haus/Git/aurora/node_modules/pirates/lib/index.js:88:7)
    at Module.load (internal/modules/cjs/loader.js:599:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
    at Function.Module._load (internal/modules/cjs/loader.js:530:3)
    at Module.require (internal/modules/cjs/loader.js:637:17)
    at require (internal/modules/cjs/helpers.js:20:18)
    at Object.<anonymous> (/Users/ev.haus/Git/aurora/packages/aurora-ux/src/Button/index.js:3:1)
    at Module._compile (internal/modules/cjs/loader.js:689:30)
    at Module._compile (/Users/ev.haus/Git/aurora/node_modules/pirates/lib/index.js:83:24)
    at Module._extensions..js (internal/modules/cjs/loader.js:700:10)
    at Object.newLoader [as .js] (/Users/ev.haus/Git/aurora/node_modules/pirates/lib/index.js:88:7)
    at Module.load (internal/modules/cjs/loader.js:599:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
    at Function.Module._load (internal/modules/cjs/loader.js:530:3)
    at Module.require (internal/modules/cjs/loader.js:637:17)
    at require (internal/modules/cjs/helpers.js:20:18)
    at Object.<anonymous> (/Users/ev.haus/Git/aurora/packages/aurora-ux/src/Accordion/AccordionSection.test.js:3:1)
    at Module._compile (internal/modules/cjs/loader.js:689:30)
    at Module._compile (/Users/ev.haus/Git/aurora/node_modules/pirates/lib/index.js:83:24)
    at Module._extensions..js (internal/modules/cjs/loader.js:700:10)
    at Object.newLoader [as .js] (/Users/ev.haus/Git/aurora/node_modules/pirates/lib/index.js:88:7)
    at Module.load (internal/modules/cjs/loader.js:599:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
    at Function.Module._load (internal/modules/cjs/loader.js:530:3)
    at Module.require (internal/modules/cjs/loader.js:637:17)
    at require (internal/modules/cjs/helpers.js:20:18)
    at /Users/ev.haus/Git/aurora/node_modules/jasmine/lib/jasmine.js:89:5
    at Array.forEach (<anonymous>)
    at Jasmine.loadSpecs (/Users/ev.haus/Git/aurora/node_modules/jasmine/lib/jasmine.js:88:18)
    at Jasmine.execute (/Users/ev.haus/Git/aurora/node_modules/jasmine/lib/jasmine.js:225:8)
    at runJasmine (/Users/ev.haus/Git/aurora/node_modules/jasmine/lib/command.js:158:11)
    at Command.run (/Users/ev.haus/Git/aurora/node_modules/jasmine/lib/command.js:56:9)
    at Object.<anonymous> (/Users/ev.haus/Git/aurora/node_modules/jasmine/bin/jasmine.js:11:9)
    at Module._compile (internal/modules/cjs/loader.js:689:30)
    at Module._compile (/Users/ev.haus/Git/aurora/node_modules/pirates/lib/index.js:83:24)
    at Module._extensions..js (internal/modules/cjs/loader.js:700:10)
    at Object.newLoader [as .js] (/Users/ev.haus/Git/aurora/node_modules/pirates/lib/index.js:88:7)
    at Module.load (internal/modules/cjs/loader.js:599:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
    at Function.Module._load (internal/modules/cjs/loader.js:530:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:742:12)
    at Object.<anonymous> (/Users/ev.haus/Git/aurora/node_modules/@babel/node/lib/_babel-node.js:224:23)
    at Module._compile (internal/modules/cjs/loader.js:689:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
    at Module.load (internal/modules/cjs/loader.js:599:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
    at Function.Module._load (internal/modules/cjs/loader.js:530:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:742:12)
    at startup (internal/bootstrap/node.js:279:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:752:3)

Expected Behavior

No failure.

Actual Behavior

A crash with the error above.

How can we reproduce the behavior?

Try to process a LESS file which has a single line comment with a ' character in it.

@shellscape
Copy link
Owner

PR welcome!

@shellscape
Copy link
Owner

FWIW the last few comments on this thread will enable a fix for this issue https://twitter.com/sitnikcode/status/1044319395760263168

@shellscape
Copy link
Owner

@EvHaus we've got a PR open on postcss to add the necessary option to allow us to work around this error. When that gets released, I'll be able to fix this issue.

@mems
Copy link

mems commented Feb 20, 2019

It's look like the issue still there, if the source code contains 2 or more line comments with a single quote:

        (1:6) Unknown word

        > 1 | // it's an inline comment with a single quote
            |      ^
          2 | // it's a line
          3 | 

Or with comment + a single quote in property value:

        (3:24) Unclosed string

          1 | // it's an inline comment with a single quote
          2 | .test{
        > 3 |   background: url('test');
            |                        ^
          4 | }
          5 | 
"postcss": "^7.0.14",
"postcss-less": "^3.1.2",

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

No branches or pull requests

3 participants