[gimp-help] Fix incorrect error when parsing <?dbtimestamp ... ?>
- From: Jacob Boerema <jboerema src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp-help] Fix incorrect error when parsing <?dbtimestamp ... ?>
- Date: Fri, 8 Jul 2022 16:31:00 +0000 (UTC)
commit feea08a0e3232fa054f25c67bf926eeb14c32ce6
Author: Jacob Boerema <jgboerema gmail com>
Date: Fri Jul 8 12:26:28 2022 -0400
Fix incorrect error when parsing <?dbtimestamp ... ?>
Code copied from validate_po.py. Maybe we should remove this validating
code from xml2po since we now have a better separate parser:
validate_po.py
(cherry picked from commit 25e2060b4e4e5131c4dbd64947b9a45fe9573ee2)
tools/xml2po/__init__.py | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
---
diff --git a/tools/xml2po/__init__.py b/tools/xml2po/__init__.py
index 735090acd..bf07b8423 100644
--- a/tools/xml2po/__init__.py
+++ b/tools/xml2po/__init__.py
@@ -366,6 +366,28 @@ class XMLDocument(object):
while start_tag > -1:
textblock = textblock[start_tag+1:]
end_tag = textblock.find('>')
+ if end_tag > 2 and textblock[0] == '!' and textblock[1] == '-' and textblock[2] == '-':
+ # Start of comment inside a translation is suspicious!
+ if not headerPrinted:
+ self.printErrorHeader(text, log)
+ headerPrinted = True
+ print(f"WARNING: Suspicious XML comment found. Skipping contents of comment.", file=log)
+ end_comment = textblock.find('-->')
+ if end_comment > -1:
+ textblock = textblock[end_comment+3:]
+ start_tag = textblock.find('<')
+ continue
+ else:
+ print(f"WARNING: XML comment closing tag missing", file=log)
+ start_tag = -1
+ continue
+ elif end_tag > 2 and textblock[0] == '?' and textblock[end_tag-1] == '?':
+ # XML "external command"
+ # This can be improved to explicitly search for end with '?>'
+ textblock = textblock[end_tag+1:]
+ start_tag = textblock.find('<')
+ continue
+
if end_tag > -1:
# Found left and right brackets: grab tag
tag = textblock[: end_tag]
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]