src/docrecord.py | 5 +++-- src/globals.py | 4 ++-- test/doc/escape.doc |binary test/doc/test.py | 5 +++++ 4 files changed, 10 insertions(+), 4 deletions(-)
New commits: commit 660f41190a78a9dc562a1ebebfa27b377d3264e7 Author: Miklos Vajna <vmik...@suse.cz> Date: Mon Jan 7 18:48:26 2013 +0100 doc: add escape testcase diff --git a/src/docrecord.py b/src/docrecord.py index e5f29fe..09e5701 100644 --- a/src/docrecord.py +++ b/src/docrecord.py @@ -31,6 +31,7 @@ class FcCompressed(DOCDirStream): print '</fcCompressed>' def getTransformedValue(self, start, end, logical = True): + lowLimit = 21 # would be only 20 by default if self.fCompressed: offset = self.fc/2 if logical: @@ -39,7 +40,7 @@ class FcCompressed(DOCDirStream): else: fro = start to = end - return globals.encodeName(self.mainStream.bytes[fro:to]) + return globals.encodeName(self.mainStream.bytes[fro:to], lowLimit = lowLimit) else: if logical: offset = self.fc @@ -48,7 +49,7 @@ class FcCompressed(DOCDirStream): else: fro = start to = end - return globals.encodeName(self.mainStream.bytes[fro:to].decode('utf-16'), lowOnly = True) + return globals.encodeName(self.mainStream.bytes[fro:to].decode('utf-16'), lowOnly = True, lowLimit = lowLimit) class Pcd(DOCDirStream): """The Pcd structure specifies the location of text in the WordDocument Stream and additional properties for this text.""" diff --git a/src/globals.py b/src/globals.py index dbb6690..e51a846 100644 --- a/src/globals.py +++ b/src/globals.py @@ -151,7 +151,7 @@ def debug (msg): sys.stderr.write("DEBUG: %s\n"%msg) -def encodeName (name, lowOnly = False): +def encodeName (name, lowOnly = False, lowLimit = 20): """Encode name that contains unprintable characters.""" n = len(name) @@ -160,7 +160,7 @@ def encodeName (name, lowOnly = False): newname = '' for i in xrange(0, n): - if ord(name[i]) <= 20 or ((not lowOnly) and ord(name[i]) >= 127): + if ord(name[i]) <= lowLimit or ((not lowOnly) and ord(name[i]) >= 127): newname += "\\x%2.2X"%ord(name[i]) else: newname += name[i] diff --git a/test/doc/escape.doc b/test/doc/escape.doc new file mode 100644 index 0000000..fa609f7 Binary files /dev/null and b/test/doc/escape.doc differ diff --git a/test/doc/test.py b/test/doc/test.py index edd39c3..5fe743c 100755 --- a/test/doc/test.py +++ b/test/doc/test.py @@ -128,6 +128,11 @@ class Test(unittest.TestCase): self.assertEqual('Hello world!', runs[0].findall('transformed')[0].attrib['value']) + def test_escape(self): + # From https://bugs.freedesktop.org/show_bug.cgi?id=59106 + # This first caused unhandled exceptions, then later invalid XML output. + self.dump('escape') + if __name__ == '__main__': unittest.main() _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits