Browse Source

Projucer: Properly escape android app names containing apostrophes

v6.1.6
reuk 4 years ago
parent
commit
65bd869451
No known key found for this signature in database GPG Key ID: 9ADCD339CFC98A11
1 changed files with 10 additions and 12 deletions
  1. +10
    -12
      extras/Projucer/Source/ProjectSaving/jucer_ProjectExport_Android.h

+ 10
- 12
extras/Projucer/Source/ProjectSaving/jucer_ProjectExport_Android.h 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;
}


Loading…
Cancel
Save