From 62a670ba3a8c06ba2e0e04782f0326cb1f61b19e Mon Sep 17 00:00:00 2001
From: Hans-Christoph Steiner <hans@eds.org>
Date: Tue, 2 May 2017 20:51:42 +0200
Subject: [PATCH] tools: check strings for odd quoting detritus

I don't know where this is coming from, and I can't see anyway that it
would be helpful
---
 app/tools/check-string-format.py | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/app/tools/check-string-format.py b/app/tools/check-string-format.py
index dcb4cadef..00395e118 100755
--- a/app/tools/check-string-format.py
+++ b/app/tools/check-string-format.py
@@ -11,6 +11,7 @@ from xml.etree import ElementTree
 formatRe = re.compile(r'(%%|%[^%](\$.)?)')
 
 validFormatRe = re.compile(r'^(%%|%[sd]|%[0-9]\$[sd])$')
+oddQuotingRe = re.compile(r'^"\s*(.+?)\s*"$')
 
 projectdir = os.path.join(os.path.dirname(__file__), '..')
 
@@ -22,6 +23,9 @@ for d in sorted(glob.glob(os.path.join(projectdir, 'src', 'main', 'res', 'values
     if not os.path.exists(str_path):
         continue
 
+    with open(str_path, encoding='utf-8') as fp:
+        fulltext = fp.read()
+
     tree = ElementTree.parse(str_path)
     root = tree.getroot()
 
@@ -36,6 +40,18 @@ for d in sorted(glob.glob(os.path.join(projectdir, 'src', 'main', 'res', 'values
             count += 1
             print('%s: Invalid format "%s" in "%s"' % (str_path, s, e.text))
 
+        m = oddQuotingRe.search(e.text)
+        if m:
+            print('%s: odd quoting in %s' % (str_path, e.tag))
+            print('found', fulltext.rfind(e.text))
+            fulltext = fulltext.replace(e.text, m.group(1))
+            count += 1
+            if e.text != m.group(1):
+                print(e.text, '-=<' + m.group(1) + '>=-')
+
+    with open(str_path, 'w', encoding='utf-8') as fp:
+        fp.write(fulltext)
+
 if count > 0:
     print("%d misformatted strings found!" % count)
     sys.exit(1)