fix(android): webview URL with large GET data#14457
Open
m1ga wants to merge 2 commits into
Open
Conversation
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.
In one of my apps I'm using a webview to display two graphs. I wanted to prefill it with data when the page is set and tried to attach all of the data using
$.www_chart.url = 'www/chart.html?data=' + encodeURIComponent(JSON.stringify(graphValues))and my app was crashing:The issue is:
Test (from an old ticket #11564 about URL query parameters):
index.html
The fix works with 640 array points attached in the URL.
The Fix:
Fix 1 — Line 587: Replaced fragile finalUri.toString().replace(query, "") with finalUri.buildUpon().clearQuery().build().toString(). This uses Uri.Builder.clearQuery() to strip the query string properly, regardless of encoding or data size. Works for both local (file:///android_asset/...) and remote (https://...) URLs.
Fix 2 — Lines 596-598: Added null-check on the InputStream after tiFile.getInputStream(). If the asset can't be opened, it throws IOException instead of an uncaught NullPointerException, so the error is handled gracefully by the existing catch block and falls through to the direct WebView load path.