From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.100; helo=mga07.intel.com; envelope-from=yonghong.zhu@intel.com; receiver=edk2-devel@lists.01.org Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) (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 C9ED921164EE1 for ; Tue, 16 Oct 2018 01:28:37 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 16 Oct 2018 01:28:37 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,387,1534834800"; d="scan'208";a="97824825" Received: from shwdeopenpsi168.ccr.corp.intel.com ([10.239.158.127]) by fmsmga004.fm.intel.com with ESMTP; 16 Oct 2018 01:28:36 -0700 From: Yonghong Zhu To: edk2-devel@lists.01.org Cc: Hess Chen Date: Tue, 16 Oct 2018 16:28:33 +0800 Message-Id: <1539678513-16968-1-git-send-email-yonghong.zhu@intel.com> X-Mailer: git-send-email 2.6.1.windows.1 Subject: [PATCH] BaseTools/UPT: Fix an issue of UNI string checking. X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 16 Oct 2018 08:28:38 -0000 From: Hess Chen The tool now can detect the error that the content between double quotes contains another double quotes or enter key. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Hess Chen --- .../Source/Python/UPT/Library/UniClassObject.py | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/BaseTools/Source/Python/UPT/Library/UniClassObject.py b/BaseTools/Source/Python/UPT/Library/UniClassObject.py index 670cf3b4ee..cd575d5a34 100644 --- a/BaseTools/Source/Python/UPT/Library/UniClassObject.py +++ b/BaseTools/Source/Python/UPT/Library/UniClassObject.py @@ -566,6 +566,22 @@ class UniFileClassObject(object): if Line.startswith(u'#language') and len(Line.split()) == 2: MultiLineFeedExits = True + # + # Check the situation that there only has one '"' for the language entry + # + if Line.startswith(u'#string') and Line.find(u'#language') > 0 and Line.count(u'"') == 1: + EdkLogger.Error("Unicode File Parser", ToolError.FORMAT_INVALID, + ExtraData='''The line %s misses '"' at the end of it in file %s''' + % (LineCount, File.Path)) + + # + # Check the situation that there has more than 2 '"' for the language entry + # + if Line.startswith(u'#string') and Line.find(u'#language') > 0 and Line.replace(u'\\"', '').count(u'"') > 2: + EdkLogger.Error("Unicode File Parser", ToolError.FORMAT_INVALID, + ExtraData='''The line %s has more than 2 '"' for language entry in file %s''' + % (LineCount, File.Path)) + # # Between two String entry, can not contain line feed # @@ -727,6 +743,13 @@ class UniFileClassObject(object): else: EdkLogger.Error("Unicode File Parser", ToolError.FORMAT_INVALID, ExtraData=File.Path) elif Line.startswith(u'"'): + # + # Check the situation that there has more than 2 '"' for the language entry + # + if Line.replace(u'\\"', '').count(u'"') > 2: + EdkLogger.Error("Unicode File Parser", ToolError.FORMAT_INVALID, + ExtraData='''The line %s has more than 2 '"' for language entry in file %s''' + % (LineCount, File.Path)) if u'#string' in Line or u'#language' in Line: EdkLogger.Error("Unicode File Parser", ToolError.FORMAT_INVALID, ExtraData=File.Path) NewLines.append(Line) -- 2.14.2.windows.2