-
-
Notifications
You must be signed in to change notification settings - Fork 151
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
Broken when content securiy policy headers are applied #8
Comments
This module does all inline by default, otherwise it would have to reserve URLs in every directory that you couldn't use. This would be awful. If you don't want inline styles, you just need to override the HTML page generation: var serveIndex = require('serveIndex')
serveIndex.html = function(req, res, files, next, dir){
// generate your index page here that
// references your own external stylesheets
// and the like
} |
Okay I already expected that security is not an issue for a module which exposes the file structure. A possible solution would be to split the request into three requests:
|
OK. Can you send a PR that does this, please? |
In the meantime I'll keep this issue open. |
Okay will look into it |
…o be compliant with content security policy
There you go. As you can see I didn't change the exports.html function so it won't break existing customized directory.html files in foreign projects. |
Thanks, I commented on your changes.
The main thing is that the |
Thanks for your feedback. What is wrong with the usage of specifying the requested mime type in the url? |
It is not working. You can see the test for the
That just seems weird. Also, you really need to encode the |
Hey - thanks for mentioning the test. The problem with csp is that inline styles are not allowed. The issue with the test was that, the tested template did not contain the {style} token anymore. |
That's OK, but people need to be able to use a custom stylesheet with the default template and the default template MUST provide a You cannot alter any existing tests, otherwise your change is not backwards-compatible for sure. |
I guess I am not explaining it well enough - custom style sheets still work but they are not inline anymore. Therefore testing if they are inline will fail. However they are part of the new "?css/text" request. |
Can you make the test check the correct place instead, then? That test must use the default template, not the template from the shared directory. |
Okay travis is testing it - please let me know if the test meets your expectations. |
Yes, they looks fine now. My only other main problem is it still isn't backwards-compatible :( because This is not terrible, but it is a breaking change and would have to hold this until a 2.0 release until this can be remedied. If you can make it so that it still works so backwards-compatibility is kept and have the external stylesheets work, that would be great and would let me put it in a 1.0 release. Another pattern that would need to work to not hold this until 2.0 is people who do not do |
You don't have to change any of those things if you don't want, but I just cannot merge it right away without the backward-compatibility kept. |
Another issue is that the documentation says that if you provide your custom template, you place a |
If you like, I can add tests for all these features to the test suite (no one says our test suite isn't lacking) and you can rebase your changes on top of the new tests so you can see what stuff you are still missing support for. |
Okay cool lets do that |
OK :) I'll let you know when I added them based tests I would like to see continue to work :) Should be sometime later today. |
@jantimon sorry for the delay; I found a couple bugs while adding tests, etc. So right now there should be most tests to help you with backwards-compatibility if you are interested. I believe I can integrate your changes in a backwards-compatible manner at this stage, though, if you are not interested in making additional changes :) |
Wow nice that sounds awesome. |
I think we are at a good point right now :) The only thing more I can think of is if you were to rebase your commits on top of the current master, but it's probably unnecessary :) I hope to this this out very soon. |
For security reasons we are disallowing inline styles and scripts.
http://www.html5rocks.com/en/tutorials/security/content-security-policy/
As we are using the same security settings in our development environments we are running into issues when using serve-index as it relies heavily on inline styles, scripts.
Any ideas how we could handle this?
The text was updated successfully, but these errors were encountered: