mirror of
https://github.com/foliojs/pdfkit.git
synced 2025-12-08 20:15:54 +00:00
Fix wrong escape of metadata when using UTF-16 (#618)
This commit is contained in:
parent
55147c4412
commit
ed07a06223
@ -38,10 +38,7 @@ class PDFObject
|
||||
|
||||
# String objects are converted to PDF strings (UTF-16)
|
||||
else if object instanceof String
|
||||
# Escape characters as required by the spec
|
||||
string = object.replace escapableRe, (c) ->
|
||||
return escapable[c]
|
||||
|
||||
string = object
|
||||
# Detect if this is a unicode string
|
||||
isUnicode = false
|
||||
for i in [0...string.length] by 1
|
||||
@ -53,6 +50,10 @@ class PDFObject
|
||||
if isUnicode
|
||||
string = swapBytes(new Buffer('\ufeff' + string, 'utf16le')).toString('binary')
|
||||
|
||||
# Escape characters as required by the spec
|
||||
string = string.replace escapableRe, (c) ->
|
||||
return escapable[c]
|
||||
|
||||
'(' + string + ')'
|
||||
|
||||
# Buffers are converted to PDF hex strings
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user