Repository navigation
fix(navigator): handle null headers when adding CORS - #841
Open
ddfreiling wants to merge 2 commits into
Open
ddfreiling wants to merge 2 commits into
ddfreiling wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
🟢 Approval recommended
Both fixes preserve existing-header behavior and address the reported crash, with a focused regression test and no identified blocking issues.
No open issues 🎉
What changed in this PR
Prevents missing allowed assets from crashing either WebView server when AndroidX returns a response without headers.
Changes:
- Handles null response headers before adding CORS, preserving existing headers.
- Adds a regression test for a missing allowed asset.
| File | Description |
|---|---|
| readium/navigators/web/internals/src/main/kotlin/org/readium/navigator/web/internals/server/WebViewServer.kt | Makes CORS handling null-safe. |
| readium/navigator/src/test/java/org/readium/r2/navigator/epub/WebViewServerTest.kt | Tests missing-asset responses and CORS headers. |
| readium/navigator/src/main/java/org/readium/r2/navigator/epub/WebViewServer.kt | Applies the same null-safe CORS fix. |
Review effort: Balanced
This branch has not been deployed
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.
Bug
Requesting an allowed asset whose file is missing from the APK can crash in WebViewServer.allowCors(): AndroidX returns a response without headers.
We encountered this after forgetting to build a helper script loaded when opening a publication. A missing asset should fail to load without crashing the app.
Fix
Use responseHeaders.orEmpty() in both WebView servers before adding CORS. Existing headers are preserved.
Validation