From 456ad438d8eabdd3b5bfa7568a600323a2b0278e Mon Sep 17 00:00:00 2001 From: Rob Wu Date: Fri, 10 Jul 2015 16:10:24 +0200 Subject: [PATCH] Issue a warning instead of an error for long Names The PDF specification (cited below) specifies a maximum length of a name in bytes as a minimal architectural limit. This means that PDF *writers* should not create names that exceed 127 bytes. It does not forbid PDF *readers* to accept such names though. These names are only used internally to link PDF objects to other objects. For these use cases, the lengths of the names do not really matter. Hence I have changed the implementation to not treat long names as errors, but warnings. > (7.3.5) The length of a name shall be subject to an implementation > limit; see Annex C. > > (Annex C.2) Table C.1 describes the minimum architectural limits that > should be accommodated by conforming readers running on 32-bit > machines. Because conforming readers may be subject to these limits, > conforming writers producing PDF files should remain within them. > > (Table C.1) name 127 "Maximum length of a name, in bytes." http://adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/PDF32000_2008.pdf --- src/core/parser.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/core/parser.js b/src/core/parser.js index d68fb5f926471..3fc9034f75810 100644 --- a/src/core/parser.js +++ b/src/core/parser.js @@ -838,9 +838,8 @@ var Lexer = (function LexerClosure() { strBuf.push(String.fromCharCode(ch)); } } - if (strBuf.length > 128) { - error('Warning: name token is longer than allowed by the spec: ' + - strBuf.length); + if (strBuf.length > 127) { + warn('name token is longer than allowed by the spec: ' + strBuf.length); } return Name.get(strBuf.join('')); },