fix(webserver): serve static .css/.js files to unauthenticated clients - #97
Merged
ngosang merged 1 commit intoJun 11, 2026
Merged
Conversation
ProcessURL() unconditionally rewrote every request from a session that is not logged in to login.php, so a logged-out browser asking for style.css got login-page HTML with the wrong Content-Type. The login page itself was therefore unable to use the shared stylesheet and had to carry an inline copy of every rule it needs. Treat stylesheets and scripts as public static assets, exactly like the template images that ProcessImgFileReq() already serves without a login, and skip the login.php override for them. This is safe: path components are stripped from the request and resolved against the template root, only names ending in .css/.js take the new path, and they are served statically with the right Content-Type -- the PHP interpreter is never involved, so no template source can leak. Other extensions still get the login page, and a missing file still yields the 404 page. With style.css reachable before login, drop the inline <style> block from login.php -- a forced duplicate of style.css rules -- and move the one rule that lived nowhere else (.login-error, the white-on-red failed-login badge) into style.css. Verified against the rebuilt amuleweb: curl without a session gets style.css as text/css while .php pages still return the login page, and headless-Chromium screenshots of the unauthenticated login page and of the wrong-password error state are pixel-identical to before.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ProcessURL() unconditionally rewrote every request from a session that is not logged in to login.php, so a logged-out browser asking for style.css got login-page HTML with the wrong Content-Type. The login page itself was therefore unable to use the shared stylesheet and had to carry an inline copy of every rule it needs.
Treat stylesheets and scripts as public static assets, exactly like the template images that ProcessImgFileReq() already serves without a login, and skip the login.php override for them. This is safe: path components are stripped from the request and resolved against the template root, only names ending in .css/.js take the new path, and they are served statically with the right Content-Type -- the PHP interpreter is never involved, so no template source can leak. Other extensions still get the login page, and a missing file still yields the 404 page.
With style.css reachable before login, drop the inline <style> block from login.php -- a forced duplicate of style.css rules -- and move the one rule that lived nowhere else (.login-error, the white-on-red failed-login badge) into style.css.
Verified against the rebuilt amuleweb: curl without a session gets style.css as text/css while .php pages still return the login page, and headless-Chromium screenshots of the unauthenticated login page and of the wrong-password error state are pixel-identical to before.