apache / cordova-ios

Apache Cordova iOS
https://cordova.apache.org/
Apache License 2.0
2.16k stars 990 forks source link

404 when startpage contains a query string and protocol/scheme are specified #909

Closed msmtamburro closed 2 weeks ago

msmtamburro commented 4 years ago

Bug Report

Problem

As soon as you specify a scheme / protocol in config.xml, even if you use the default, app://localhost, requests will then start to go through CDVURLSchemeHandler.m. Here, they can pass through [[NSData alloc] initWithContentsOfFile:startPath] which returns nil if the startPage has a query string, resulting in a 404.

What is expected to happen?

The query string should be stripped before using initWithContentsOfFile:. The file URL could be constructed with URL components instead of strings, so that it is possible to omit things like query strings safely.

What does actually happen?

initWithContentsOfFile: does not know what to do with the query string, so you get a 404.

Information

Note: this possibly also fails with fragments... I did not test. And, it might be helpful to document scheme and protocol so developers might understand why they would customize these.

Command or Code

  1. set your startPage to index.html?whoops
  2. specify preferences in config.xml for scheme and protocol

Environment, Platform, Device

iOS 13

Version information

cordova-ios 6.0

Checklist