mirror of https://github.com/acidanthera/audk.git
BaseTools: Add special handle for '\' use in Pcd Value
V2: Follow PEP8 to not multiples import on one line Case: gEfiOzmosisPkgTokenSpaceGuid.PcdBootLogFolderPath|L"\\Logs\\"|VOID*|12 Fixes: https://bugzilla.tianocore.org/show_bug.cgi?id=1287 Cc: Liming Gao <liming.gao@intel.com> Cc: Yonghong Zhu <yonghong.zhu@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Zhiju.Fan <zhijux.fan@intel.com> Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
This commit is contained in:
parent
5b9639e697
commit
d3d97b378f
|
@ -22,6 +22,8 @@ import Common.EdkLogger as EdkLogger
|
||||||
import copy
|
import copy
|
||||||
from Common.DataType import *
|
from Common.DataType import *
|
||||||
import sys
|
import sys
|
||||||
|
from random import sample
|
||||||
|
import string
|
||||||
|
|
||||||
ERR_STRING_EXPR = 'This operator cannot be used in string expression: [%s].'
|
ERR_STRING_EXPR = 'This operator cannot be used in string expression: [%s].'
|
||||||
ERR_SNYTAX = 'Syntax error, the rest of expression cannot be evaluated: [%s].'
|
ERR_SNYTAX = 'Syntax error, the rest of expression cannot be evaluated: [%s].'
|
||||||
|
@ -55,6 +57,8 @@ PcdPattern = re.compile(r'[_a-zA-Z][0-9A-Za-z_]*\.[_a-zA-Z][0-9A-Za-z_]*$')
|
||||||
#
|
#
|
||||||
def SplitString(String):
|
def SplitString(String):
|
||||||
# There might be escaped quote: "abc\"def\\\"ghi", 'abc\'def\\\'ghi'
|
# There might be escaped quote: "abc\"def\\\"ghi", 'abc\'def\\\'ghi'
|
||||||
|
RanStr = ''.join(sample(string.ascii_letters + string.digits, 8))
|
||||||
|
String = String.replace('\\\\', RanStr).strip()
|
||||||
RetList = []
|
RetList = []
|
||||||
InSingleQuote = False
|
InSingleQuote = False
|
||||||
InDoubleQuote = False
|
InDoubleQuote = False
|
||||||
|
@ -87,11 +91,16 @@ def SplitString(String):
|
||||||
raise BadExpression(ERR_STRING_TOKEN % Item)
|
raise BadExpression(ERR_STRING_TOKEN % Item)
|
||||||
if Item:
|
if Item:
|
||||||
RetList.append(Item)
|
RetList.append(Item)
|
||||||
|
for i, ch in enumerate(RetList):
|
||||||
|
if RanStr in ch:
|
||||||
|
RetList[i] = ch.replace(RanStr,'\\\\')
|
||||||
return RetList
|
return RetList
|
||||||
|
|
||||||
def SplitPcdValueString(String):
|
def SplitPcdValueString(String):
|
||||||
# There might be escaped comma in GUID() or DEVICE_PATH() or " "
|
# There might be escaped comma in GUID() or DEVICE_PATH() or " "
|
||||||
# or ' ' or L' ' or L" "
|
# or ' ' or L' ' or L" "
|
||||||
|
RanStr = ''.join(sample(string.ascii_letters + string.digits, 8))
|
||||||
|
String = String.replace('\\\\', RanStr).strip()
|
||||||
RetList = []
|
RetList = []
|
||||||
InParenthesis = 0
|
InParenthesis = 0
|
||||||
InSingleQuote = False
|
InSingleQuote = False
|
||||||
|
@ -124,6 +133,9 @@ def SplitPcdValueString(String):
|
||||||
raise BadExpression(ERR_STRING_TOKEN % Item)
|
raise BadExpression(ERR_STRING_TOKEN % Item)
|
||||||
if Item:
|
if Item:
|
||||||
RetList.append(Item)
|
RetList.append(Item)
|
||||||
|
for i, ch in enumerate(RetList):
|
||||||
|
if RanStr in ch:
|
||||||
|
RetList[i] = ch.replace(RanStr,'\\\\')
|
||||||
return RetList
|
return RetList
|
||||||
|
|
||||||
def IsValidCName(Str):
|
def IsValidCName(Str):
|
||||||
|
@ -390,7 +402,7 @@ class ValueExpression(BaseExpression):
|
||||||
elif not Val:
|
elif not Val:
|
||||||
Val = False
|
Val = False
|
||||||
RealVal = '""'
|
RealVal = '""'
|
||||||
elif not Val.startswith('L"') and not Val.startswith('{') and not Val.startswith("L'"):
|
elif not Val.startswith('L"') and not Val.startswith('{') and not Val.startswith("L'") and not Val.startswith("'"):
|
||||||
Val = True
|
Val = True
|
||||||
RealVal = '"' + RealVal + '"'
|
RealVal = '"' + RealVal + '"'
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,7 @@ import re
|
||||||
import pickle
|
import pickle
|
||||||
import array
|
import array
|
||||||
import shutil
|
import shutil
|
||||||
|
from random import sample
|
||||||
from struct import pack
|
from struct import pack
|
||||||
from UserDict import IterableUserDict
|
from UserDict import IterableUserDict
|
||||||
from UserList import UserList
|
from UserList import UserList
|
||||||
|
@ -1236,7 +1237,8 @@ def IsFieldValueAnArray (Value):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def AnalyzePcdExpression(Setting):
|
def AnalyzePcdExpression(Setting):
|
||||||
Setting = Setting.strip()
|
RanStr = ''.join(sample(string.ascii_letters + string.digits, 8))
|
||||||
|
Setting = Setting.replace('\\\\', RanStr).strip()
|
||||||
# There might be escaped quote in a string: \", \\\" , \', \\\'
|
# There might be escaped quote in a string: \", \\\" , \', \\\'
|
||||||
Data = Setting
|
Data = Setting
|
||||||
# There might be '|' in string and in ( ... | ... ), replace it with '-'
|
# There might be '|' in string and in ( ... | ... ), replace it with '-'
|
||||||
|
@ -1269,7 +1271,9 @@ def AnalyzePcdExpression(Setting):
|
||||||
break
|
break
|
||||||
FieldList.append(Setting[StartPos:Pos].strip())
|
FieldList.append(Setting[StartPos:Pos].strip())
|
||||||
StartPos = Pos + 1
|
StartPos = Pos + 1
|
||||||
|
for i, ch in enumerate(FieldList):
|
||||||
|
if RanStr in ch:
|
||||||
|
FieldList[i] = ch.replace(RanStr,'\\\\')
|
||||||
return FieldList
|
return FieldList
|
||||||
|
|
||||||
def ParseDevPathValue (Value):
|
def ParseDevPathValue (Value):
|
||||||
|
|
Loading…
Reference in New Issue