Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fontique] fontconfig: allow_dtd for xml config #44

Merged
merged 1 commit into from
Apr 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion fontique/src/backend/fontconfig/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,13 @@ pub fn parse_config(path: &Path, sink: &mut impl ParserSink) {
let Ok(text) = std::fs::read_to_string(path) else {
return;
};
let Ok(doc) = roxmltree::Document::parse(&text) else {
let Ok(doc) = roxmltree::Document::parse_with_options(
&text,
roxmltree::ParsingOptions {
allow_dtd: true,
nodes_limit: u32::MAX,
DJMcNab marked this conversation as resolved.
Show resolved Hide resolved
},
) else {
return;
Copy link
Member

@DJMcNab DJMcNab Apr 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not having any error handling here is a bit weird - there's a real difference between "the file doesn't exist, so try the next file" (?), and "the file does exist but is malformed XML"

Although I see that's a pre-existing choice

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I don't have a great answer for this. We can surface some sort of error which I suppose would have helped us catch this particular bug but in the general case, there's no real way to guard against the user having either a broken font configuration or one that we're incapable of reading.

};
let root = doc.root_element();
Expand Down