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

feat: support http w/ content src fix #1298

Merged
merged 1 commit into from Jul 30, 2021
Merged

Conversation

erisu
Copy link
Member

@erisu erisu commented Jul 28, 2021

Motivation and Context

fixes: #1296
fixes: #1289
fixes: #1299

Description

setStartUrl was being called during the parsing of the config.xml. This should not be called until after the parsing has been completed. The reason why this was an issue is because setStartUrl was called when the content tag was being parsed. Some or all preference tags may not have been already loaded, so therefore we do not have the information to best determin what the start url should be.

This PR moves the setStartUrl in side the getLaunchUrl. The first call of getLaunchUrl will trigger the setStartUrl method. Any calls there after will return immediately the launchUrl as it will be saved from the first call.

With the changes described above, it resolved the reported issue in #1289.

Additionally, this PR allows users to set the scheme between http and https. These are the only valid schemes for the WebViewAssetLoader. If the user supplied anything that is not valid, it will default to https

Also to continue to maintain a best secure pratice, the default with no defined scheme will also be https.

Testing

  • npm t
  • cordova build
  • Tested Use Cases
    • scheme+hostname+content:src=<file> Test
      • http, localhost, index.html
      • http, localhost, test/index.html
      • http, localhost, page.html
      • https, localhost, index.html
      • https, localhost, test/index.html
      • https, localhost, page.html
      • http, foobar, index.html
      • http, foobar, test/index.html
      • http, foobar, page.html
      • https, foobar, index.html
      • https, foobar, test/index.html
      • https, foobar, page.html
    • AndroidInsecureFileModeEnabled=true (file://) Test
      • index.html
      • test/index.html
      • page.html
    • content:src=<URL>
    • https://cordova.apache.org/

Checklist

  • I've run the tests to see all new and existing tests pass
  • If this Pull Request resolves an issue, I linked to the issue in the text above (and used the correct keyword to close issues using keywords)

@erisu erisu added this to the 10.1.0 milestone Jul 28, 2021
@codecov-commenter
Copy link

codecov-commenter commented Jul 28, 2021

Codecov Report

Merging #1298 (111d842) into master (e69ab6a) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #1298   +/-   ##
=======================================
  Coverage   73.25%   73.25%           
=======================================
  Files          21       21           
  Lines        1645     1645           
=======================================
  Hits         1205     1205           
  Misses        440      440           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e69ab6a...111d842. Read the comment docs.

Copy link
Contributor

@breautek breautek left a comment

Choose a reason for hiding this comment

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

lgtm

Copy link
Contributor

@AdriVanHoudt AdriVanHoudt left a comment

Choose a reason for hiding this comment

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

This seems to fix #1299.

Added a small nit but lgtm otherwise (I can only vouch for the workings regarding #1299 not scheme stuff :P)

return scheme + "://" + hostname + '/';
}
}

private void setStartUrl(String src) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Just for someone not familiar with this code, I would rename this to setLaunchUrl.

@erisu erisu added this to Reviewer approved in Release Plan - 10.1.0 Jul 30, 2021
@erisu erisu merged commit 1636d70 into apache:master Jul 30, 2021
Release Plan - 10.1.0 automation moved this from Reviewer approved to Done Jul 30, 2021
@erisu erisu deleted the feat/http-support branch July 30, 2021 08:08
zachawilson added a commit to SwitchCaseGroup/public-cordova-plugin-browsertab that referenced this pull request Aug 4, 2021
zachawilson added a commit to SwitchCaseGroup/cordova-app-hello-world that referenced this pull request Aug 10, 2021
this isn't needed now that it has been identified that the issue was apache/cordova-android#1298
schlusslicht added a commit to wooportal/client that referenced this pull request Dec 23, 2021
schlusslicht added a commit to wooportal/client that referenced this pull request Dec 23, 2021
wedgberto pushed a commit to wedgberto/cordova-android that referenced this pull request May 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
4 participants