Skip to content

Commit

Permalink
fix(GH-1432): Default content src when content tag is missing (#1573)
Browse files Browse the repository at this point in the history
  • Loading branch information
breautek committed Mar 21, 2023
1 parent dbddbf2 commit d4bfd50
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion framework/src/org/apache/cordova/ConfigXmlParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public class ConfigXmlParser {
private static String SCHEME_HTTP = "http";
private static String SCHEME_HTTPS = "https";
private static String DEFAULT_HOSTNAME = "localhost";
private static final String DEFAULT_CONTENT_SRC = "index.html";

private String launchUrl;
private String contentSrc;
Expand Down Expand Up @@ -110,6 +111,18 @@ else if (eventType == XmlPullParser.END_TAG)
e.printStackTrace();
}
}

onPostParse();
}

private void onPostParse() {
// After parsing, if contentSrc is still null, it signals
// that <content> tag was completely missing. In this case,
// default it.
// https://github.com/apache/cordova-android/issues/1432
if (contentSrc == null) {
contentSrc = DEFAULT_CONTENT_SRC;
}
}

public void handleStartTag(XmlPullParser xml) {
Expand Down Expand Up @@ -140,7 +153,7 @@ else if (strNode.equals("content")) {
contentSrc = src;
} else {
// Default
contentSrc = "index.html";
contentSrc = DEFAULT_CONTENT_SRC;
}
}
}
Expand Down

0 comments on commit d4bfd50

Please sign in to comment.