1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

Projucer: Properly escape android app names containing apostrophes

This commit is contained in:
reuk 2021-08-17 16:33:28 +01:00
parent 5f7ad995af
commit 65bd869451
No known key found for this signature in database
GPG key ID: 9ADCD339CFC98A11

View file

@ -589,7 +589,7 @@ private:
MemoryOutputStream mo;
mo.setNewLineString (getNewLineString());
mo << "rootProject.name = " << "\'" << projectName << "\'" << newLine;
mo << "rootProject.name = " << "\'" << escapeQuotes (projectName) << "\'" << newLine;
mo << (isLibrary() ? "include ':lib'" : "include ':app'");
auto extraContent = androidGradleSettingsContent.get().toString();
@ -1281,6 +1281,11 @@ private:
return "android-" + androidMinimumSDK.get().toString();
}
static String escapeQuotes (const String& str)
{
return str.replace ("'", "\\'").replace ("\"", "\\\"");
}
//==============================================================================
void writeStringsXML (const File& folder) const
{
@ -1289,7 +1294,7 @@ private:
auto& cfg = dynamic_cast<const AndroidBuildConfiguration&> (*config);
String customStringsXmlContent ("<resources>\n");
customStringsXmlContent << "<string name=\"app_name\">" << projectName << "</string>\n";
customStringsXmlContent << "<string name=\"app_name\">" << escapeQuotes (projectName) << "</string>\n";
customStringsXmlContent << cfg.getCustomStringsXml();
customStringsXmlContent << "\n</resources>";
@ -1579,20 +1584,13 @@ private:
for (int i = 0; i < defs.size(); ++i)
{
auto escaped = "\"-D" + defs.getAllKeys()[i];
auto escaped = "[[-D" + defs.getAllKeys()[i];
auto value = defs.getAllValues()[i];
if (value.isNotEmpty())
{
value = value.replace ("\"", "\\\"");
if (value.containsChar (L' ') && ! value.startsWith ("\\\"") && ! value.endsWith ("\\\""))
value = "\\\"" + value + "\\\"";
escaped += ("=" + value);
}
escapedDefs.add (escaped + "\"");
escapedDefs.add (escaped + "]]");
}
return escapedDefs;
@ -1603,7 +1601,7 @@ private:
StringArray escaped;
for (auto& flag : flags)
escaped.add ("\"" + flag + "\"");
escaped.add ("[[" + flag + "]]");
return escaped;
}