Merging upstream version 0.1.2.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
8c164cbb1d
commit
78a50327fa
5 changed files with 51 additions and 4 deletions
2
PKG-INFO
2
PKG-INFO
|
@ -1,6 +1,6 @@
|
|||
Metadata-Version: 2.1
|
||||
Name: pydyf
|
||||
Version: 0.1.1
|
||||
Version: 0.1.2
|
||||
Summary: A low-level PDF generator.
|
||||
Keywords: pdf,generator
|
||||
Author-email: CourtBouillon <contact@courtbouillon.org>
|
||||
|
|
|
@ -2,6 +2,44 @@ Changelog
|
|||
=========
|
||||
|
||||
|
||||
Version 0.1.2
|
||||
-------------
|
||||
|
||||
Released on 2021-10-30.
|
||||
|
||||
Bug fixes:
|
||||
|
||||
* `#9 <https://github.com/CourtBouillon/pydyf/pull/9>`_:
|
||||
Implement escaping for Strings
|
||||
|
||||
Contributors:
|
||||
|
||||
* Guillaume Ayoub
|
||||
* Rian McGuire
|
||||
|
||||
Backers and sponsors:
|
||||
|
||||
* Grip Angebotssoftware
|
||||
* SimonSoft
|
||||
* Menutech
|
||||
* Manuel Barkhau
|
||||
* Simon Sapin
|
||||
* KontextWork
|
||||
* René Fritz
|
||||
* Maykin Media
|
||||
* NCC Group
|
||||
* Crisp BV
|
||||
* Des images et des mots
|
||||
* Andreas Zettl
|
||||
* Nathalie Gutton
|
||||
* Tom Pohl
|
||||
* Moritz Mahringer
|
||||
* Florian Demmer
|
||||
* Yanal-Yvez Fargialla
|
||||
* G. Allard
|
||||
* Gábor
|
||||
|
||||
|
||||
Version 0.1.1
|
||||
-------------
|
||||
|
||||
|
|
|
@ -3,10 +3,11 @@ A low-level PDF generator.
|
|||
|
||||
"""
|
||||
|
||||
import re
|
||||
import zlib
|
||||
from codecs import BOM_UTF16_BE
|
||||
|
||||
VERSION = __version__ = '0.1.1'
|
||||
VERSION = __version__ = '0.1.2'
|
||||
|
||||
|
||||
def _to_bytes(item):
|
||||
|
@ -375,7 +376,12 @@ class String(Object):
|
|||
@property
|
||||
def data(self):
|
||||
try:
|
||||
return b'(' + _to_bytes(self.string) + b')'
|
||||
# "A literal string is written as an arbitrary number of characters
|
||||
# enclosed in parentheses. Any characters may appear in a string
|
||||
# except unbalanced parentheses and the backslash, which must be
|
||||
# treated specially."
|
||||
escaped = re.sub(rb'([\\\(\)])', rb'\\\1', _to_bytes(self.string))
|
||||
return b'(' + escaped + b')'
|
||||
except UnicodeEncodeError:
|
||||
encoded = BOM_UTF16_BE + str(self.string).encode('utf-16-be')
|
||||
return b'<' + encoded.hex().encode() + b'>'
|
||||
|
|
2
setup.py
2
setup.py
|
@ -19,7 +19,7 @@ extras_require = \
|
|||
'pillow']}
|
||||
|
||||
setup(name='pydyf',
|
||||
version='0.1.1',
|
||||
version='0.1.2',
|
||||
description='A low-level PDF generator.',
|
||||
author=None,
|
||||
author_email='CourtBouillon <contact@courtbouillon.org>',
|
||||
|
|
|
@ -706,3 +706,6 @@ def test_string_encoding():
|
|||
assert pydyf.String('abc').data == b'(abc)'
|
||||
assert pydyf.String('déf').data == b'<feff006400e90066>'
|
||||
assert pydyf.String('♡').data == b'<feff2661>'
|
||||
assert pydyf.String('\\abc').data == b'(\\\\abc)'
|
||||
assert pydyf.String('abc(').data == b'(abc\\()'
|
||||
assert pydyf.String('ab)c').data == b'(ab\\)c)'
|
||||
|
|
Loading…
Add table
Reference in a new issue