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

fix(GH-1432): Default content src when content tag is missing #1573

Merged
merged 1 commit into from
Mar 21, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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