Skip to content
Closed
Show file tree
Hide file tree
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
5 changes: 5 additions & 0 deletions src/core/file_format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,9 @@ pub enum FileFormat {
/// Plain text format (.txt)
TXT,

/// HTML / XHTML document (.htm, .html, .xhtml)
HTML,

/// Windows shortcut (.lnk)
LNK,

Expand Down Expand Up @@ -378,6 +381,7 @@ impl FileFormat {
FileFormat::ICS => "iCalendar",
FileFormat::EML => "EML",
FileFormat::TXT => "TXT",
FileFormat::HTML => "HTML",
FileFormat::LNK => "Windows Shortcut",
FileFormat::SQLite => "SQLite",
FileFormat::Prefetch => "Windows Prefetch",
Expand Down Expand Up @@ -478,6 +482,7 @@ impl FileFormat {
FileFormat::ICS => &["ics", "ical"],
FileFormat::EML => &["eml", "email"],
FileFormat::TXT => &["txt", "text"],
FileFormat::HTML => &["htm", "html", "xhtml"],
FileFormat::LNK => &["lnk"],
FileFormat::SQLite => &["db", "sqlite", "sqlite3"],
FileFormat::Prefetch => &["pf"],
Expand Down
2 changes: 2 additions & 0 deletions src/core/format_dispatch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ use crate::parsers::specialized::sqlite::parse_sqlite_metadata;
use crate::parsers::specialized::stl::parse_stl_metadata;
use crate::parsers::specialized::x509::parse_x509_metadata;
use crate::parsers::text::eps::parse_eps_metadata;
use crate::parsers::text::html::parse_html_metadata;
use crate::parsers::text::txt::parse_txt_metadata;
use crate::parsers::text::vcf::parse_vcf_metadata;
use crate::parsers::video::asf::parse_asf_metadata;
Expand Down Expand Up @@ -170,6 +171,7 @@ pub fn dispatch_format_parser(reader: &dyn FileReader, format: FileFormat) -> Re
FileFormat::HDF5 => convert_string_error(parse_hdf5_metadata(reader), "HDF5"),
FileFormat::VCF => convert_string_error(parse_vcf_metadata(reader), "VCF"),
FileFormat::TXT => convert_string_error(parse_txt_metadata(reader), "TXT"),
FileFormat::HTML => convert_string_error(parse_html_metadata(reader), "HTML"),
FileFormat::LNK => convert_string_error(parse_lnk_metadata(reader), "LNK"),
FileFormat::SQLite => convert_string_error(parse_sqlite_metadata(reader), "SQLite"),
FileFormat::ICS => convert_string_error(parse_ics_metadata(reader), "ICS"),
Expand Down
12 changes: 12 additions & 0 deletions src/parsers/detection/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,18 @@ pub fn detect_format(reader: &dyn FileReader) -> io::Result<FileFormat> {
return Ok(FileFormat::Plist);
}

// HTML and XHTML, using ExifTool's own gate from `HTML.pm`'s ProcessHTML.
// It runs after the SVG and plist roots because those three share the
// `<?xml` opening: ExifTool requires an actual HTML element in the first
// 256 bytes before it will accept an XML declaration as HTML, which is
// what keeps SVG, XMP sidecars and XML plists out. Before this existed
// every .html file fell through to the plain-text fallback and was parsed
// as TXT, reporting five TEXT:* statistics ExifTool never reports and none
// of the 57 HTML/Dublin-Core/Office tags it does.
if crate::parsers::text::html::looks_like_html(magic_bytes) {
return Ok(FileFormat::HTML);
}

// Text-based formats need a wider bounded probe for long ICS bodies and EML header blocks.
let text_probe_len = reader
.size()
Expand Down
2 changes: 1 addition & 1 deletion src/parsers/font/ttf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ impl TTFParser {
}

/// Decodes a string using the Macintosh Roman encoding.
fn decode_mac_roman(data: &[u8]) -> String {
pub(crate) fn decode_mac_roman(data: &[u8]) -> String {
const MAC_ROMAN_HIGH: [char; 128] = [
'Ä', 'Å', 'Ç', 'É', 'Ñ', 'Ö', 'Ü', 'á', 'à', 'â', 'ä', 'ã', 'å', 'ç', 'é', 'è', 'ê',
'ë', 'í', 'ì', 'î', 'ï', 'ñ', 'ó', 'ò', 'ô', 'ö', 'õ', 'ú', 'ù', 'û', 'ü', '†', '°',
Expand Down
Loading
Loading