]> git.proxmox.com Git - mirror_edk2.git/commitdiff
BaseTools/UPT: Fix an issue of UNI string checking.
authorHess Chen <hesheng.chen@intel.com>
Tue, 16 Oct 2018 06:04:00 +0000 (14:04 +0800)
committerYonghong Zhu <yonghong.zhu@intel.com>
Wed, 24 Oct 2018 00:41:05 +0000 (08:41 +0800)
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>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
BaseTools/Source/Python/UPT/Library/UniClassObject.py

index 670cf3b4eeac19a9f945f06c575b593eed6463d0..cd575d5a341095c593d8d2c157b9726919455870 100644 (file)
@@ -566,6 +566,22 @@ class UniFileClassObject(object):
             if Line.startswith(u'#language') and len(Line.split()) == 2:\r
                 MultiLineFeedExits = True\r
 \r
+            #\r
+            # Check the situation that there only has one '"' for the language entry\r
+            #\r
+            if Line.startswith(u'#string') and Line.find(u'#language') > 0 and Line.count(u'"') == 1:\r
+                EdkLogger.Error("Unicode File Parser", ToolError.FORMAT_INVALID,\r
+                                ExtraData='''The line %s misses '"' at the end of it in file %s'''\r
+                                % (LineCount, File.Path))\r
+\r
+            #\r
+            # Check the situation that there has more than 2 '"' for the language entry\r
+            #\r
+            if Line.startswith(u'#string') and Line.find(u'#language') > 0 and Line.replace(u'\\"', '').count(u'"') > 2:\r
+                EdkLogger.Error("Unicode File Parser", ToolError.FORMAT_INVALID,\r
+                                ExtraData='''The line %s has more than 2 '"' for language entry in file %s'''\r
+                                % (LineCount, File.Path))\r
+\r
             #\r
             # Between two String entry, can not contain line feed\r
             #\r
@@ -727,6 +743,13 @@ class UniFileClassObject(object):
                 else:\r
                     EdkLogger.Error("Unicode File Parser", ToolError.FORMAT_INVALID, ExtraData=File.Path)\r
             elif Line.startswith(u'"'):\r
+                #\r
+                # Check the situation that there has more than 2 '"' for the language entry\r
+                #\r
+                if Line.replace(u'\\"', '').count(u'"') > 2:\r
+                    EdkLogger.Error("Unicode File Parser", ToolError.FORMAT_INVALID,\r
+                                    ExtraData='''The line %s has more than 2 '"' for language entry in file %s'''\r
+                                    % (LineCount, File.Path))\r
                 if u'#string' in Line  or u'#language' in Line:\r
                     EdkLogger.Error("Unicode File Parser", ToolError.FORMAT_INVALID, ExtraData=File.Path)\r
                 NewLines.append(Line)\r