Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

chore(*): fix serving of URI-encoded files on code.angularjs.org #16943

Closed
wants to merge 2 commits into from

Conversation

gkalpak
Copy link
Member

@gkalpak gkalpak commented Feb 1, 2020

The files served for the various versions on https://code.angularjs.org/ are retrieved by a Firebase function from a Firebase Storage bucket (where they are deployed to from Travis CI). The files are stored exactly as they are named on disk.

It turns out that some of the files have names with special characters that get URI-encoded when sent to the Firebase function. For example, input[text].html becomes input%5Btext%5D.html. As a result, the actual file cannot be retrieved from the Storage bucket (since the name does not match) and index.html is returned instead. Apparently, this never worked, but nobody noticed or reported it until recently.

An example of a failing URL is: https://code.angularjs.org/1.7.9/docs/api/ng/input/input%5Btext%5D

(NOTE: https://docs.angularjs.org/ works correctly, since the files are deployed to Firebase hosting directly and not to a Storage bucket.)

This commit fixes the problem by decoding the request path before trying to retrieve the corresponding file from the Storage bucket.

The files served for the various versions on https://code.angularjs.org/
are retrieved by a Firebase function from a Firebase Storage bucket
(where they are deployed to from Travis CI). The files are stored
exactly as they are named on disk.

It turns out that some of the files have names with special characters
that get URI-encoded when sent to the Firebase function. For example,
`input[text].html` becomes `input%5Btext%5D.html`. As a result, the
actual file cannot be retrieved from the Storage bucket (since the name
does not match) and `index.html` is returned instead. Apparently, this
never worked, but nobody noticed or reported it until recently.

An example of a failing URL is:
https://code.angularjs.org/1.7.9/docs/api/ng/input/input%5Btext%5D

(NOTE: https://docs.angularjs.org/ works correctly, since the files are
deployed to Firebase hosting directly and not to a Storage bucket.)

This commit fixes the problem by decoding the request path before trying
to retrieve the corresponding file from the Storage bucket.
@gkalpak
Copy link
Member Author

gkalpak commented Feb 1, 2020

This PR just includes the code changes that are needed to fix this. The actual fix is deploying the updated code to Firebase.

BTW, I have manually verified that the fix works by deploying the code to a test Firebase project on my account.

@gkalpak gkalpak closed this in 68701ef Feb 2, 2020
gkalpak added a commit that referenced this pull request Feb 2, 2020
The files served for the various versions on https://code.angularjs.org/
are retrieved by a Firebase function from a Firebase Storage bucket
(where they are deployed to from Travis CI). The files are stored
exactly as they are named on disk.

It turns out that some of the files have names with special characters
that get URI-encoded when sent to the Firebase function. For example,
`input[text].html` becomes `input%5Btext%5D.html`. As a result, the
actual file cannot be retrieved from the Storage bucket (since the name
does not match) and `index.html` is returned instead. Apparently, this
never worked, but nobody noticed or reported it until recently.

An example of a failing URL is:
https://code.angularjs.org/1.7.9/docs/api/ng/input/input%5Btext%5D

(NOTE: https://docs.angularjs.org/ works correctly, since the files are
deployed to Firebase hosting directly and not to a Storage bucket.)

This commit fixes the problem by decoding the request path before trying
to retrieve the corresponding file from the Storage bucket.

Closes #16943
@gkalpak
Copy link
Member Author

gkalpak commented Feb 2, 2020

Deployed to Firebase and the fix is live. Example:

@gkalpak gkalpak deleted the fix-code-angularjs-org branch February 2, 2020 13:57
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants