* [PATCH] BaseTools: Fix parse GUID expression issue
@ 2020-05-06 4:55 Feng, YunhuaX
0 siblings, 0 replies; only message in thread
From: Feng, YunhuaX @ 2020-05-06 4:55 UTC (permalink / raw)
To: devel@edk2.groups.io; +Cc: Feng, Bob C, Gao, Liming
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2686
some GUID include character ' or " ascii value, transfer to string will
catch the wrong value.
Cc: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Signed-off-by: Yunhua Feng <yunhuax.feng@intel.com>
---
BaseTools/Source/Python/Common/Misc.py | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/BaseTools/Source/Python/Common/Misc.py b/BaseTools/Source/Python/Common/Misc.py
index da5fb380f0..ad55671080 100755
--- a/BaseTools/Source/Python/Common/Misc.py
+++ b/BaseTools/Source/Python/Common/Misc.py
@@ -37,10 +37,11 @@ from Common.LongFilePathSupport import OpenLongFilePath as open
from Common.LongFilePathSupport import CopyLongFilePath as CopyLong
from Common.LongFilePathSupport import LongFilePath as LongFilePath
from Common.MultipleWorkspace import MultipleWorkspace as mws
from CommonDataClass.Exceptions import BadExpression
from Common.caching import cached_property
+import struct
ArrayIndex = re.compile("\[\s*[0-9a-fA-FxX]*\s*\]")
## Regular expression used to find out place holders in string template
gPlaceholderPattern = re.compile("\$\{([^$()\s]+)\}", re.MULTILINE | re.UNICODE)
@@ -1153,17 +1154,16 @@ def ParseFieldValue (Value):
raise BadExpression("Invalid GUID value string %s" % Value)
Value = TmpValue
if Value[0] == '"' and Value[-1] == '"':
Value = Value[1:-1]
try:
- Value = str(uuid.UUID(Value).bytes_le)
- if Value.startswith("b'"):
- Value = Value[2:-1]
- Value = "'" + Value + "'"
+ Value = uuid.UUID(Value).bytes_le
+ ValueL, ValueH = struct.unpack('2Q', Value)
+ Value = (ValueH << 64 ) | ValueL
+
except ValueError as Message:
raise BadExpression(Message)
- Value, Size = ParseFieldValue(Value)
return Value, 16
if Value.startswith('L"') and Value.endswith('"'):
# Unicode String
# translate escape character
Value = Value[1:]
--
2.12.2.windows.2
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2020-05-06 4:55 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-05-06 4:55 [PATCH] BaseTools: Fix parse GUID expression issue Feng, YunhuaX
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox