Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(346)

Unified Diff: tools/grit/grit/tool/xmb_unittest.py

Issue 2697383002: Fix xmb_unittest.py in GRIT. (Closed)
Patch Set: Correct sequence for \U00110000. Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/grit/grit/tool/xmb.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/grit/grit/tool/xmb_unittest.py
diff --git a/tools/grit/grit/tool/xmb_unittest.py b/tools/grit/grit/tool/xmb_unittest.py
index df8e84b6200c021c7f2be53849a967b124edefc1..200ecd9a594b1ce8128f4e30385246e2b97a6ac7 100755
--- a/tools/grit/grit/tool/xmb_unittest.py
+++ b/tools/grit/grit/tool/xmb_unittest.py
@@ -12,6 +12,7 @@ if __name__ == '__main__':
import unittest
import StringIO
+import xml.sax
from grit import grd_reader
from grit import util
@@ -103,6 +104,25 @@ class XmbUnittest(unittest.TestCase):
output = self.xmb_file.getvalue()
self.failUnless(output.count('OK ? </msg>'))
+ def testDisallowedChars(self):
+ # Validate that the invalid unicode is not accepted. Since it's not valid,
+ # we can't specify it in a string literal, so write as a byte sequence.
+ bad_xml = StringIO.StringIO()
+ bad_xml.write('''<?xml version="1.0" encoding="UTF-8"?>
+ <grit latest_public_release="2" source_lang_id="en-US"
+ current_release="3" base_dir=".">
+ <release seq="3">
+ <messages>
+ <message name="ID_FOO">''')
+ # UTF-8 corresponding to to \U00110000
+ # http://apps.timwhitlock.info/unicode/inspect/hex/110000
+ bad_xml.write(b'\xF4\x90\x80\x80')
+ bad_xml.write('''</message>
+ </messages>
+ </release>
+ </grit>''')
+ bad_xml.seek(0)
+ self.assertRaises(xml.sax.SAXParseException, grd_reader.Parse, bad_xml, '.')
if __name__ == '__main__':
unittest.main()
« no previous file with comments | « tools/grit/grit/tool/xmb.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698