Skip to content

fix(webserver): serve static .css/.js files to unauthenticated clients - #97

Merged
ngosang merged 1 commit into
amule-org:masterfrom
ngosang:fix/serve-css-js-unauthenticated
Jun 11, 2026
Merged

fix(webserver): serve static .css/.js files to unauthenticated clients#97
ngosang merged 1 commit into
amule-org:masterfrom
ngosang:fix/serve-css-js-unauthenticated

Conversation

@ngosang

@ngosang ngosang commented Jun 11, 2026

Copy link
Copy Markdown
Member

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.

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.
@ngosang
ngosang merged commit 2a61287 into amule-org:master Jun 11, 2026
9 checks passed
@ngosang
ngosang deleted the fix/serve-css-js-unauthenticated branch June 11, 2026 12:30
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

Successfully merging this pull request may close these issues.

1 participant