diff --git a/translate/storage/dtd.py b/translate/storage/dtd.py index 3d303938a6..b1a96cfe6d 100644 --- a/translate/storage/dtd.py +++ b/translate/storage/dtd.py @@ -58,7 +58,7 @@ def quotefordtd(source): if '%' in source: - source = source.replace("%", "") + source = source.replace("%", "%") if '"' in source: if "'" in source: return "'" + source.replace("'", ''') + "'" @@ -77,7 +77,7 @@ def unquotefromdtd(source): extracted, quotefinished = quote.extractwithoutquotes(source, quotechar, quotechar, allowreentry=False) if quotechar == "'" and "'" in extracted: extracted = extracted.replace("'", "'") - extracted = extracted.replace("", "%") + extracted = extracted.replace("%", "%") # the quote characters should be the first and last characters in the string # of course there could also be quote characters within the string; not handled here return extracted @@ -471,6 +471,7 @@ def _valid_store(self): try: # #expand is a Mozilla hack and are removed as they are not valid in DTDs dtd = etree.DTD(StringIO.StringIO(re.sub("#expand", "", self.getoutput()))) - except etree.DTDParseError: + except etree.DTDParseError as e: + warnings.warn("DTD parse error: %s" % e.error_log) return False return True diff --git a/translate/storage/test_dtd.py b/translate/storage/test_dtd.py index 7f878519e8..e84e27852e 100644 --- a/translate/storage/test_dtd.py +++ b/translate/storage/test_dtd.py @@ -31,7 +31,7 @@ def tester(raw_original, dtd_ready_result): assert dtd.quotefordtd(raw_original) == dtd_ready_result #print dtd.unquotefromdtd(dtd_ready_result) assert dtd.unquotefromdtd(dtd_ready_result) == raw_original - tester("Unintentional variable %S", '"Unintentional variable S"') + tester("Unintentional variable %S", '"Unintentional variable %S"') def test_removeinvalidamp(recwarn): """tests the the removeinvalidamps function"""