chiark / gitweb /
Add an extra strip() to work around tostring issue
authorDaniel Martí <mvdan@mvdan.cc>
Sun, 25 Oct 2015 23:28:29 +0000 (00:28 +0100)
committerDaniel Martí <mvdan@mvdan.cc>
Sun, 25 Oct 2015 23:28:29 +0000 (00:28 +0100)
In cases like this xml code:

<string name="app_name">"OpenKeychain"</string>
<!-- title -->
<string name="title_encrypt_text">"Encrypt"</string>

tostring() returns trailing whitespaces (including newlines). Which
aren't removed until the very end, after we try to remove enclosing
quotes. So strip right after tostring() too, since we never really care
about whitespaces anyway.

fdroidserver/common.py

index 47db0101e1a25b55de91bd7697457d5483ad0fbd..db2e0f09faaa01d6f61f4df85691b0c02fa3966a 100644 (file)
@@ -914,7 +914,8 @@ def retrieve_string(app_dir, string, xmlfiles=None):
     def element_content(element):
         if element.text is None:
             return ""
-        return XMLElementTree.tostring(element, encoding='utf-8', method='text')
+        s = XMLElementTree.tostring(element, encoding='utf-8', method='text')
+        return s.strip()
 
     for path in xmlfiles:
         if not os.path.isfile(path):