-
-
Notifications
You must be signed in to change notification settings - Fork 4k
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
[stable12] CSSResourceLocator: handle SCSS in apps outside root #7257
[stable12] CSSResourceLocator: handle SCSS in apps outside root #7257
Conversation
d8e37ea
to
7a143c0
Compare
Currently static CSS files work fine in apps outside of the root. However, as soon as an app uses SCSS, Nextcloud starts being unable to find the web root. Fix this problem by backporting select snippets from master specifically targeting this issue, and add a test to ensure it doesn't regress. Fix nextcloud#5289 Signed-off-by: Kyle Fazzari <kyrofa@ubuntu.com>
7a143c0
to
7f8f3dc
Compare
Codecov Report
@@ Coverage Diff @@
## stable12 #7257 +/- ##
==============================================
+ Coverage 53.79% 53.86% +0.06%
- Complexity 22590 22594 +4
==============================================
Files 1384 1384
Lines 86666 86667 +1
Branches 1329 1329
==============================================
+ Hits 46620 46681 +61
+ Misses 40046 39986 -60
|
(The failed test does not seem related.) |
@rullzer @nickvergessen @LukasReschke @karlitschek Opinions on getting this into 12.0.4 and building an RC2? |
I can't judge the importance and the risk. Your call @MorrisJobke :-) |
Well if we don't do this, apps should not be allowed to use SCSS at all, because the app dev can not know where their app is installed to. And I think it looks easy enough, so if it works why not. |
@kyrofa We definitely should put an advertisement if the scss file is unreachable though. Because without alias for apache or root change for nginx, the webserver can't serve a file outside of its allowed declared roots. It could lead to confusion for the user. |
This PR fixed the issues in two apps with 12.0.0. Cheers! 👍 |
Failing test is unrelated |
Doesn't seem to work here: And the path to the css is generated as The problem is that Or which paths were we trying to fix here? |
@nickvergessen path outside your default root :) |
@skjnldsv I'm not quite clear on what you're saying here. The SCSS file isn't served up by Apache or Nginx, it's compiled and then cached into the data dir as CSS, then served by Nextcloud itself (which is why paths look like |
@kyrofa, well, without alias this wont' work. Nginx have to serve the correct files. This is not only related to scss. :) |
@skjnldsv unless I misunderstand something (always possible!), SCSS files should work fine without an alias, it's CSS files (and other static assets in the app) that won't. Here are a few URLs in the head using the Calendar app (which uses static CSS):
All of those require an alias. However, take a look at a CSS URL for SCSS (using the Contacts app):
Note how compiled SCSS, being in the data dir, is not served as a static asset using the webserver, but as a dynamic one using PHP. This particular case, as far as I can see, does not involve the alias. That's not to say it's not important, of course, or all the other stuff would break 😛 . |
Okay, I mixed up two different issues. This one is only about the scss fetch from the scss lib. :)
@kyrofa I built the scss integration in nextcloud! ;) |
No offense intended my friend! I simply wasn't sure what you were talking about, so I tried to be as explicit as possible 😃 . |
To clarify, does this look okay, then? |
Though it works for me, I'm wondering whether it wouldn't make more sense to proxy any asset through the standard This would avoid having to rewrite URLs or fiddle with the server's configuration. |
That's well beyond what master does today. I suspect that's probably not suitable for a backport. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems to do the trick for me
Thank you! This will improve my self-hosted Nextcloud a lot! @shtrom Do not forget the case when Nginx does not have access to the files: |
On Mon 27 Nov 2017 at 10:53:01 +0000, tYYGH wrote:
@shtrom Do not forget the case when Nginx does not have access to the files: `try_files` is useless in such situations.
Oh, yeah, I was just taking it as an example of behaviour, but it would need to
be reimplemented in a server-agnostic way.
…--
Olivier Mehani <shtrom@ssji.net>
PGP fingerprint: 4435 CF6A 7C8D DD9B E2DE F5F9 F012 A6E2 98C6 6655
Confidentiality cannot be guaranteed on emails sent or received unencrypted.
|
Do you have an ETA for the release or should I apply the patch manually? |
Thursday is the planned one. |
Nice! |
Currently static CSS files work fine in apps outside of the root. However, as soon as an app uses SCSS, Nextcloud starts being unable to find the web root.
This PR fixes #5289 by backporting select snippets from master specifically targeting this issue (note that master does not have this issue), and adding a test to ensure it doesn't regress.