@@ -27,7 +27,7 @@ def test_pofile_and_mofile1(self):
2727 data = u ('''# test for pofile/mofile with string buffer
2828msgid ""
2929msgstr ""
30- "Project-Id-Version: django\n "
30+ "Project-Id-Version: django"
3131
3232msgid "foo"
3333msgstr "bar"
@@ -116,7 +116,7 @@ def test_ufeff_data_pofile(self):
116116 data = u ('''\ufeff # test for pofile/mofile with ufeff
117117msgid ""
118118msgstr ""
119- "Project-Id-Version: django\n "
119+ "Project-Id-Version: django"
120120
121121msgid "foo"
122122msgstr "bar"
@@ -258,6 +258,35 @@ def test_unescaped_double_quote4(self):
258258 msg = 'Syntax error in po file (line 4): unescaped double quote found'
259259 self .assertEqual (str (exc ), msg )
260260
261+ def test_no_double_quote_delimiters (self ):
262+ """
263+ Test that polib reports an error when a string is not delimited by double quotes.
264+ """
265+ invalid_msgstr = r'''
266+ msgid "A"
267+ msgstr *B"
268+ '''
269+ invalid_msgid = r'''
270+ msgid "A/
271+ msgstr "B"
272+ '''
273+ invalid_msgid_plural = r'''
274+ msgid_plural A
275+ msgstr "B"
276+ '''
277+ invalid_msgstr_continuation = r'''
278+ msgid "A"
279+ msgstr ""
280+ "B
281+ '''
282+ for data in (invalid_msgid , invalid_msgid_plural , invalid_msgstr , invalid_msgstr_continuation ):
283+ try :
284+ polib .pofile (data )
285+ self .fail ("Strings not delimited by double quotes not detected" )
286+ except IOError as ex :
287+ msg = 'string not delimited by double quotes'
288+ self .assertIn (msg , str (ex ))
289+
261290 def test_syntax_error1 (self ):
262291 """
263292 Test that syntax error is raised while processing a symbol parsing.
0 commit comments