Skip to content

Commit

Permalink
Issue a warning instead of an error for long Names
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Rob--W committed Jul 10, 2015
1 parent eb2ad11 commit 456ad43
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/core/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(''));
},
Expand Down

0 comments on commit 456ad43

Please sign in to comment.