From 2eee2943cce2a7aea7a11b93f2459f5f333eb84c Mon Sep 17 00:00:00 2001 From: Gregor Jasny Date: Sun, 2 Aug 2015 00:06:49 +0200 Subject: [PATCH] Xcode: Invert quoting logic to whitelist of characters Our explicit list of characters that require quoting does not account for non-ascii characters (e.g. UTF-8) that also need quoting. Invert the logic to quote a string unless it contains exclusively a set of characters we whitelist. --- Source/cmXCodeObject.cxx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Source/cmXCodeObject.cxx b/Source/cmXCodeObject.cxx index ba6e39517..c59c3609f 100644 --- a/Source/cmXCodeObject.cxx +++ b/Source/cmXCodeObject.cxx @@ -243,7 +243,11 @@ void cmXCodeObject::PrintString(std::ostream& os,std::string String) bool needQuote = (String.empty() || String.find("//") != String.npos || - String.find_first_of(" <>+-*=@[](){},~") != String.npos); + String.find_first_not_of( + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "abcdefghijklmnopqrstuvwxyz" + "0123456789" + "$_./") != String.npos); const char* quote = needQuote? "\"" : ""; // Print the string, quoted and escaped as necessary.