Skip to content

Commit ee75ff5

Browse files
jfkthamekhaledhosny
authored andcommitted
Introduce new TABLE_ACTION_SANITIZE_SOFT action.
This action (not used as the default for any table tags) performs the same table-specific Parse() as TABLE_ACTION_SANITIZE, but if parsing fails, it will drop the table but _not_ return a failure status to the overall processing. This can be used by a client that wishes to continue processing and using a resource even if certain tables may fail sanitization and be discarded. It differs from SANITIZE in that failure to parse does not completely stop processing of the resource and return an overall failure. It differs from PASS_THRU in that the table is subject to sanitization, reporting any errors found, and will be dropped if it fails, rather than silently accepted. It differs from DROP in that the table is only dropped if (unrecoverable) errors are found by Parse(); if the table is valid, it will be retained.
1 parent 0c307fe commit ee75ff5

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

include/opentype-sanitiser.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,9 @@ enum TableAction {
172172
TABLE_ACTION_DEFAULT, // Use OTS's default action for that table
173173
TABLE_ACTION_SANITIZE, // Sanitize the table, potentially dropping it
174174
TABLE_ACTION_PASSTHRU, // Serialize the table unchanged
175-
TABLE_ACTION_DROP // Drop the table
175+
TABLE_ACTION_DROP, // Drop the table
176+
TABLE_ACTION_SANITIZE_SOFT, // Sanitize the table, but without failing overall
177+
// sanitzation even if this table fails/is dropped
176178
};
177179

178180
class OTSContext {

src/ots.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1045,6 +1045,12 @@ bool Font::ParseTable(const TableEntry& table_entry, const uint8_t* data,
10451045
ret = table->Parse(table_data, table_length);
10461046
if (ret)
10471047
AddTable(table_entry, table);
1048+
else if (action == TABLE_ACTION_SANITIZE_SOFT) {
1049+
// We're dropping the table (having reported whatever errors we found),
1050+
// but do not return failure, so that processing continues.
1051+
delete table;
1052+
ret = true;
1053+
}
10481054
}
10491055
}
10501056

0 commit comments

Comments
 (0)