mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 13:47:35 +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();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue