From: Yonghong Zhu <yonghong.zhu@intel.com>
To: edk2-devel@lists.01.org
Cc: Hess Chen <hesheng.chen@intel.com>
Subject: [PATCH] BaseTools/UPT: Fix an issue of UNI string checking.
Date: Tue, 16 Oct 2018 16:28:33 +0800 [thread overview]
Message-ID: <1539678513-16968-1-git-send-email-yonghong.zhu@intel.com> (raw)
From: Hess Chen <hesheng.chen@intel.com>
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 <hesheng.chen@intel.com>
---
.../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
next reply other threads:[~2018-10-16 8:28 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-16 8:28 Yonghong Zhu [this message]
2018-10-23 12:35 ` [PATCH] BaseTools/UPT: Fix an issue of UNI string checking Zhu, Yonghong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1539678513-16968-1-git-send-email-yonghong.zhu@intel.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox