lib/hexapdf/encryption/security_handler.rb in hexapdf-0.24.2 vs lib/hexapdf/encryption/security_handler.rb in hexapdf-0.25.0

- old
+ new

@@ -284,12 +284,15 @@ obj end # Returns the encrypted version of the string that resides in the given indirect object. # + # Note that some strings won't be encrypted as per the specification. The returned string, + # however, is always a different object. + # # See: PDF1.7 s7.6.2 def encrypt_string(str, obj) - return str if str.empty? || obj == document.trailer[:Encrypt] || obj.type == :XRef || + return str.dup if str.empty? || obj == document.trailer[:Encrypt] || obj.type == :XRef || (obj.type == :Sig && obj[:Contents].equal?(str)) key = object_key(obj.oid, obj.gen, string_algorithm) string_algorithm.encrypt(key, str) end