Skip to content
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

fix: handle URL encoded paths in AppOverrideFilter #20009

Merged
merged 3 commits into from
Feb 21, 2025
Merged

Conversation

netroms
Copy link
Contributor

@netroms netroms commented Feb 20, 2025

Summary

The AppOverrideFilter was incorrectly handling paths containing URL encoded characters (like spaces encoded as %20) by extracting the "raw" encoded URL with the request.getRequestURI() method. This caused issues with file paths containing spaces, such as font files (e.g. "Open Sans Regular").

The fix simplifies the path handling by using request.getPathInfo() which provides the correct decoded path after the servlet mapping part of the URL. This ensures proper handling of paths containing spaces and other URL encoded characters, while also being more maintainable by using the standard Servlet API as intended.

Manual test:

  1. Try to access the URL: http://localhost:8080/dhis-web-maps/fonts/Open Sans Bold/6144-6399.pbf (double check on the file system that this path actually exist in the installed/overridden app folder, the .pdf file names can vary)
  2. Make sure you can access it.
  3. Install an overridden app version from the "App management" app. We chose to install the map app, since it contains fonts that have spaces in it.
  4. Try to access the same URL: http://localhost:8080/dhis-web-maps/fonts/Open Sans Bold/6144-6399.pbf (make sure it actually exists on file system first, the .pbf files can vary from map app version)
  5. Make sure you also can access it.

TIP: The file system path for installed apps looks similar to this: DHIS2_HOME_FOLDER/files/apps/maps_101.0.1/fonts/Open Sans Bold

@netroms netroms requested a review from a team as a code owner February 20, 2025 18:24
Copy link
Contributor

@david-mackessy david-mackessy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was a request like /dhis-web-maps/fonts/Open%20Sans%20Regular/0-255.pbf checked to see if that works also?
Also, I know Spring filters are hard to test in our setup so testing this is very difficult. Without actually looking into how to test this, it seems a shame not to have a test for something that could easily be changed again in the future. Just calling it out.

@netroms netroms merged commit d317186 into master Feb 21, 2025
17 checks passed
@netroms netroms deleted the DHIS2-19029 branch February 21, 2025 07:28
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.

3 participants