mirror of
https://github.com/storytold/pdfcraft.git
synced 2026-11-10 18:31:10 -06:00
fix(render): vendor hayro-postscript so a run of << in a CMap can't overflow the stack (#4363)
hayro-cmap reads CMap streams with hayro-postscript's token scanner, whose object::read skipped each `<<` and `>>` by calling itself again. A CMap holding a long run of `<` or `>` used one stack frame per pair, overflowed the stack and aborted the process. Vendor hayro-postscript 0.1.0 with read() looping over the delimiters instead (from storytold/craft-libs#263), patched in beside hayro-cmap. Four object::tests cover long `<<` and `>>` runs and the skipped delimiters, plain and nested.
This commit is contained in:
Vendored
+30
@@ -0,0 +1,30 @@
|
||||
//! Error types for the PostScript scanner.
|
||||
|
||||
use core::fmt;
|
||||
|
||||
/// A specialized [`Result`] type for PostScript scanner operations.
|
||||
pub type Result<T> = core::result::Result<T, Error>;
|
||||
|
||||
/// An error encountered while scanning a PostScript token stream.
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub enum Error {
|
||||
/// A syntax error in the input.
|
||||
SyntaxError,
|
||||
/// A numeric value exceeded implementation limits.
|
||||
LimitCheck,
|
||||
/// An unsupported PostScript type was encountered (like dictionaries or
|
||||
/// procedures, which will be added in the future).
|
||||
UnsupportedType,
|
||||
}
|
||||
|
||||
impl fmt::Display for Error {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
Self::SyntaxError => f.write_str("syntaxerror"),
|
||||
Self::LimitCheck => f.write_str("limitcheck"),
|
||||
Self::UnsupportedType => f.write_str("unsupported type"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl core::error::Error for Error {}
|
||||
Reference in New Issue
Block a user