* [PATCH v2] BaseTools: Fix parse PCD GUID expression issue
@ 2020-05-09 0:14 Feng, YunhuaX
2020-05-13 2:16 ` Bob Feng
0 siblings, 1 reply; 2+ messages in thread
From: Feng, YunhuaX @ 2020-05-09 0:14 UTC (permalink / raw)
To: devel@edk2.groups.io; +Cc: Feng, Bob C, Gao, Liming
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2686
The build tool will give an incorrect GUID value if the GUID includes character ' or " ASCII value.
This patch is going to fix this issue.
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] 2+ messages in thread
* Re: [PATCH v2] BaseTools: Fix parse PCD GUID expression issue
2020-05-09 0:14 [PATCH v2] BaseTools: Fix parse PCD GUID expression issue Feng, YunhuaX
@ 2020-05-13 2:16 ` Bob Feng
0 siblings, 0 replies; 2+ messages in thread
From: Bob Feng @ 2020-05-13 2:16 UTC (permalink / raw)
To: Feng, YunhuaX, devel@edk2.groups.io; +Cc: Gao, Liming
Reviewed-by: Bob Feng <bob.c.feng@intel.com>
-----Original Message-----
From: Feng, YunhuaX <yunhuax.feng@intel.com>
Sent: Saturday, May 9, 2020 8:15 AM
To: devel@edk2.groups.io
Cc: Feng, Bob C <bob.c.feng@intel.com>; Gao, Liming <liming.gao@intel.com>
Subject: [PATCH v2] BaseTools: Fix parse PCD GUID expression issue
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2686
The build tool will give an incorrect GUID value if the GUID includes character ' or " ASCII value.
This patch is going to fix this issue.
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] 2+ messages in thread
end of thread, other threads:[~2020-05-13 2:16 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-05-09 0:14 [PATCH v2] BaseTools: Fix parse PCD GUID expression issue Feng, YunhuaX
2020-05-13 2:16 ` Bob Feng
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox