You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cordova.apache.org by GitBox <gi...@apache.org> on 2021/07/28 09:19:16 UTC

[GitHub] [cordova-android] erisu opened a new pull request #1298: feat: support http w/ content src fix

erisu opened a new pull request #1298:
URL: https://github.com/apache/cordova-android/pull/1298


   ### Motivation and Context
   
   fixes: #1296
   fixes: #1289
   
   ### 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
   
   - [x] I've run the tests to see all new and existing tests pass
   - [x] 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](https://help.github.com/articles/closing-issues-using-keywords/))
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


[GitHub] [cordova-android] codecov-commenter edited a comment on pull request #1298: feat: support http w/ content src fix

Posted by GitBox <gi...@apache.org>.
codecov-commenter edited a comment on pull request #1298:
URL: https://github.com/apache/cordova-android/pull/1298#issuecomment-888154217


   # [Codecov](https://codecov.io/gh/apache/cordova-android/pull/1298?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#1298](https://codecov.io/gh/apache/cordova-android/pull/1298?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (111d842) into [master](https://codecov.io/gh/apache/cordova-android/commit/e69ab6a6879071262cd82e527fba8bf141ec7240?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (e69ab6a) will **not change** coverage.
   > The diff coverage is `n/a`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/cordova-android/pull/1298/graphs/tree.svg?width=650&height=150&src=pr&token=q14nMf6C5a&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)](https://codecov.io/gh/apache/cordova-android/pull/1298?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   
   ```diff
   @@           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](https://codecov.io/gh/apache/cordova-android/pull/1298?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/cordova-android/pull/1298?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [e69ab6a...111d842](https://codecov.io/gh/apache/cordova-android/pull/1298?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


[GitHub] [cordova-android] AdriVanHoudt commented on a change in pull request #1298: feat: support http w/ content src fix

Posted by GitBox <gi...@apache.org>.
AdriVanHoudt commented on a change in pull request #1298:
URL: https://github.com/apache/cordova-android/pull/1298#discussion_r678953783



##########
File path: framework/src/org/apache/cordova/ConfigXmlParser.java
##########
@@ -147,20 +149,40 @@ public void handleEndTag(XmlPullParser xml) {
         }
     }
 
+    private String getLaunchUrlPrefix() {
+        if (prefs.getBoolean("AndroidInsecureFileModeEnabled", false)) {
+            return "file:///android_asset/www/";
+        } else {
+            String scheme = prefs.getString("scheme", SCHEME_HTTPS).toLowerCase();
+            String hostname = prefs.getString("hostname", DEFAULT_HOSTNAME);
+
+            if (!scheme.contentEquals(SCHEME_HTTP) && !scheme.contentEquals(SCHEME_HTTPS)) {
+                LOG.d(TAG, "The provided scheme \"" + scheme + "\" is not valid. " +
+                    "Defaulting to \"" + SCHEME_HTTPS + "\". " +
+                    "(Valid Options=" + SCHEME_HTTP + "," + SCHEME_HTTPS + ")");
+
+                scheme = SCHEME_HTTPS;
+            }
+
+            return scheme + "://" + hostname + '/';
+        }
+    }
+
     private void setStartUrl(String src) {

Review comment:
       Just for someone not familiar with this code, I would rename this to `setLaunchUrl`.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


[GitHub] [cordova-android] codecov-commenter commented on pull request #1298: feat: support http w/ content src fix

Posted by GitBox <gi...@apache.org>.
codecov-commenter commented on pull request #1298:
URL: https://github.com/apache/cordova-android/pull/1298#issuecomment-888154217


   # [Codecov](https://codecov.io/gh/apache/cordova-android/pull/1298?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#1298](https://codecov.io/gh/apache/cordova-android/pull/1298?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (111d842) into [master](https://codecov.io/gh/apache/cordova-android/commit/e69ab6a6879071262cd82e527fba8bf141ec7240?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (e69ab6a) will **not change** coverage.
   > The diff coverage is `n/a`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/cordova-android/pull/1298/graphs/tree.svg?width=650&height=150&src=pr&token=q14nMf6C5a&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)](https://codecov.io/gh/apache/cordova-android/pull/1298?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   
   ```diff
   @@           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](https://codecov.io/gh/apache/cordova-android/pull/1298?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/cordova-android/pull/1298?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [e69ab6a...111d842](https://codecov.io/gh/apache/cordova-android/pull/1298?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


[GitHub] [cordova-android] erisu merged pull request #1298: feat: support http w/ content src fix

Posted by GitBox <gi...@apache.org>.
erisu merged pull request #1298:
URL: https://github.com/apache/cordova-android/pull/1298


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org