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

URLs are not properly escaped! #53

Closed
Pigsnuck opened this issue May 19, 2020 · 4 comments
Closed

URLs are not properly escaped! #53

Pigsnuck opened this issue May 19, 2020 · 4 comments

Comments

@Pigsnuck
Copy link

Pigsnuck commented May 19, 2020

After quite a bit of digging, I found out why cordova-plugin-wkwebkit-file-xhr is not correctly loading Mapbox GL JS URLs, even when the following preference is set in config.xml.

<preference name="InterceptRemoteRequests" value="all" />

The following error is displayed any time I want to get a MapBox URL:

ERROR: {"message":"Bad Request"}

The reason is simple (but hard to find!): URLs are not being correctly escaped!
The fix is even simpler.

Replace line 339 in platforms/iOS/[Project Name]/Plugins/CDVWKWebViewFileXhr.m from this:

NSURL *url = [NSURL URLWithString:urlString];

To this:

NSURL *url;
if ([urlString rangeOfString:@"%"].location == NSNotFound) {
    url = [NSURL URLWithString:[urlString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
} else {
    url = [NSURL URLWithString:urlString];
}

I haven't bothered to create a pull request, as Oracle have stated they will not accept them. You will have to apply this patch manually.

@Pigsnuck
Copy link
Author

Update: I created a fork with my fix. You can use that in your Cordova project if you prefer.

See: https://github.com/Pigsnuck/cordova-plugin-wkwebview-file-xhr

@manish2788
Copy link
Member

Thanks @Pigsnuck. We will get back to you upon this with the fix

@manish2788
Copy link
Member

@Pigsnuck Can you provide a sample app demonstrating the issue you faced.

@manish2788
Copy link
Member

Closing this issue due to lack of response.

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

No branches or pull requests

2 participants