mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 17:27:46 +00:00
LibPDF: Don't use unsanitized values in error messages
Previously, constructing error messages with unsanitized input could fail because error message strings must be UTF-8.
This commit is contained in:
parent
f8bf9c6506
commit
b4296e1c9b
9 changed files with 41 additions and 15 deletions
|
@ -37,14 +37,16 @@ PDFErrorOr<NonnullRefPtr<PDFFont>> PDFFont::create(Document* document, NonnullRe
|
|||
auto subtype = TRY(dict->get_name(document, CommonNames::Subtype))->name();
|
||||
|
||||
RefPtr<PDFFont> font;
|
||||
if (subtype == "Type1")
|
||||
if (subtype == "Type1") {
|
||||
font = adopt_ref(*new Type1Font());
|
||||
else if (subtype == "TrueType")
|
||||
} else if (subtype == "TrueType") {
|
||||
font = adopt_ref(*new TrueTypeFont());
|
||||
else if (subtype == "Type0")
|
||||
} else if (subtype == "Type0")
|
||||
font = adopt_ref(*new Type0Font());
|
||||
else
|
||||
return Error::internal_error("Unhandled font subtype: {}", subtype);
|
||||
else {
|
||||
dbgln_if(PDF_DEBUG, "Unhandled font subtype: {}", subtype);
|
||||
return Error::internal_error("Unhandled font subtype");
|
||||
}
|
||||
|
||||
TRY(font->initialize(document, dict, font_size));
|
||||
return font.release_nonnull();
|
||||
|
|
|
@ -284,7 +284,7 @@ PDFErrorOr<Type1FontProgram::Glyph> Type1FontProgram::parse_glyph(ReadonlyBytes
|
|||
i += 2;
|
||||
TRY(push(a));
|
||||
} else {
|
||||
return error(DeprecatedString::formatted("CFF Subr command 28 only valid in type2 data"));
|
||||
return error("CFF Subr command 28 only valid in type2 data");
|
||||
}
|
||||
} else {
|
||||
// Not a parameter but a command byte.
|
||||
|
@ -494,7 +494,8 @@ PDFErrorOr<Type1FontProgram::Glyph> Type1FontProgram::parse_glyph(ReadonlyBytes
|
|||
break;
|
||||
|
||||
default:
|
||||
return error(DeprecatedString::formatted("Unhandled command: 12 {}", data[i]));
|
||||
dbgln_if(PDF_DEBUG, "Unhandled command: 12 {}", data[i]);
|
||||
return error("Unhandled command");
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -578,7 +579,8 @@ PDFErrorOr<Type1FontProgram::Glyph> Type1FontProgram::parse_glyph(ReadonlyBytes
|
|||
}
|
||||
|
||||
default:
|
||||
return error(DeprecatedString::formatted("Unhandled command: {}", v));
|
||||
dbgln_if(PDF_DEBUG, "Unhandled command: {}", v);
|
||||
return error("Unhandled command");
|
||||
}
|
||||
|
||||
is_first_command = false;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue