-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
The value of window.__karma__.files is not properly escaped #1876
Comments
It seems that this issue can be solved for single quotes, but for double quotes... Well, you should never create double quotes in a filename. So, I worked on a fix and test for this and will provide a PR this evening for it. |
Would it not be easier to use: return util.format(" %s: '%s'", JSON.stringify(filePath), file.sha) This way you can not make any mistake in the escaping. console.log(JSON.stringify('foo\n"bar"')) // "foo\n\"bar\"" |
There are some cases that when a character is escaped the loading of the file would go wrong. The most safe way would be to find the cases that are 'common' and escape only those characters. |
How so? All that we are doing is passing a JavaScript variable from one context (node) to another (the browser), |
…er#1876. fix(karma): Escape quotes for file names. This fixes issue karma-runner#1876.
I'm still hitting this problem in the latest release: https://github.com/karma-runner/karma/releases/tag/v0.13.22 |
One of the files being served in my project has a single quote in its name. Karma is unable to run any tests because of this.
This is the culprit:
karma/lib/middleware/karma.js
Line 148 in 19dd824
Why not use
JSON.stringify()
?The text was updated successfully, but these errors were encountered: