From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.151; helo=mga17.intel.com; envelope-from=yonghong.zhu@intel.com; receiver=edk2-devel@lists.01.org Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id DC86621F0DA49 for ; Mon, 5 Feb 2018 17:05:59 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 05 Feb 2018 17:11:41 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,467,1511856000"; d="scan'208";a="15280327" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by orsmga007.jf.intel.com with ESMTP; 05 Feb 2018 17:11:41 -0800 Received: from fmsmsx118.amr.corp.intel.com (10.18.116.18) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.319.2; Mon, 5 Feb 2018 17:11:40 -0800 Received: from shsmsx152.ccr.corp.intel.com (10.239.6.52) by fmsmsx118.amr.corp.intel.com (10.18.116.18) with Microsoft SMTP Server (TLS) id 14.3.319.2; Mon, 5 Feb 2018 17:11:40 -0800 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.116]) by SHSMSX152.ccr.corp.intel.com ([169.254.6.130]) with mapi id 14.03.0319.002; Tue, 6 Feb 2018 09:11:38 +0800 From: "Zhu, Yonghong" To: "Feng, YunhuaX" , "edk2-devel@lists.01.org" CC: "Gao, Liming" , "Zhu, Yonghong" Thread-Topic: [PATCH] BaseTools: Report error GUID format if incorrectly Thread-Index: AdOeM1KcDipz8oAVSGGLhyEHG1bHJwAtBM+w Date: Tue, 6 Feb 2018 01:11:38 +0000 Message-ID: References: <47C64442C08CCD4089DC43B6B5E46BC482962B@shsmsx102.ccr.corp.intel.com> In-Reply-To: <47C64442C08CCD4089DC43B6B5E46BC482962B@shsmsx102.ccr.corp.intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH] BaseTools: Report error GUID format if incorrectly X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 06 Feb 2018 01:06:00 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Yonghong Zhu =20 Best Regards, Zhu Yonghong -----Original Message----- From: Feng, YunhuaX=20 Sent: Monday, February 05, 2018 11:43 AM To: edk2-devel@lists.01.org Cc: Zhu, Yonghong ; Gao, Liming Subject: [PATCH] BaseTools: Report error GUID format if incorrectly Flexible GUID format support like these: 1. { GUID("11E13869-1896-4A07-8B21-D8B23DD2A2B4") } 2. { GUID({ 0x11e13869,= 0x1896, 0x4a07,{ 0x8b, 0x21, 0xd8, 0xb2, 0x3d, 0xd2, 0xa2, 0xb4 } }) } 3. { GUID(gEfiBlo= ckIoProtocolGuid) } Cc: Liming Gao Cc: Yonghong Zhu Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Yunhua Feng --- BaseTools/Source/Python/Common/Misc.py | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/BaseTools/Source/Python/Common/Misc.py b/BaseTools/Source/Pyth= on/Common/Misc.py index b8c2ce1ddc..5a0bcd9bf7 100644 --- a/BaseTools/Source/Python/Common/Misc.py +++ b/BaseTools/Source/Python/Common/Misc.py @@ -1535,16 +1535,10 @@ def ParseFieldValue (Value): if Value.startswith('GUID') and Value.endswith(')'): Value =3D Value.split('(', 1)[1][:-1].strip() if Value[0] =3D=3D '{' and Value[-1] =3D=3D '}': - Value =3D Value[1:-1].strip() - Value =3D Value.split('{', 1) - Value =3D ['%02x' % int(Item, 16) for Item in (Value[0] + Valu= e[1][:-1]).split(',')] - if len(Value[0]) !=3D 8: - Value[0] =3D '%08X' % int(Value[0], 16) - if len(Value[1]) !=3D 4: - Value[1] =3D '%04X' % int(Value[1], 16) - if len(Value[2]) !=3D 4: - Value[2] =3D '%04X' % int(Value[2], 16) - Value =3D '-'.join(Value[0:3]) + '-' + ''.join(Value[3:5]) + '= -' + ''.join(Value[5:11]) + TmpValue =3D GuidStructureStringToGuidString(Value) + if len(TmpValue) =3D=3D 0: + raise BadExpression("Invalid GUID value string %s" % Value= ) + Value =3D TmpValue if Value[0] =3D=3D '"' and Value[-1] =3D=3D '"': Value =3D Value[1:-1] try: -- 2.12.2.windows.2