]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/Common/Misc.py
BaseTools: Add special handle for '\' use in Pcd Value
[mirror_edk2.git] / BaseTools / Source / Python / Common / Misc.py
index b32b7cdc5fe1175c74b1a76cc6cd00f433bab241..3b8efb2e7179b177d648b74bb64bd1eab495ac8d 100644 (file)
@@ -24,6 +24,7 @@ import re
 import pickle\r
 import array\r
 import shutil\r
+from random import sample\r
 from struct import pack\r
 from UserDict import IterableUserDict\r
 from UserList import UserList\r
@@ -1236,7 +1237,8 @@ def IsFieldValueAnArray (Value):
     return False\r
 \r
 def AnalyzePcdExpression(Setting):\r
-    Setting = Setting.strip()\r
+    RanStr = ''.join(sample(string.ascii_letters + string.digits, 8))\r
+    Setting = Setting.replace('\\\\', RanStr).strip()\r
     # There might be escaped quote in a string: \", \\\" , \', \\\'\r
     Data = Setting\r
     # There might be '|' in string and in ( ... | ... ), replace it with '-'\r
@@ -1269,7 +1271,9 @@ def AnalyzePcdExpression(Setting):
             break\r
         FieldList.append(Setting[StartPos:Pos].strip())\r
         StartPos = Pos + 1\r
-\r
+    for i, ch in enumerate(FieldList):\r
+        if RanStr in ch:\r
+            FieldList[i] = ch.replace(RanStr,'\\\\')\r
     return FieldList\r
 \r
 def ParseDevPathValue (Value):\r