From 21338ed7897a3c7dd3319861d2c7ed35c4fbeb58 Mon Sep 17 00:00:00 2001 From: David Peter Date: Thu, 8 Jul 2021 23:00:11 +0300 Subject: [PATCH] Abort ignored filename suffix stripping early on unworkable filenames --- src/assets.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/assets.rs b/src/assets.rs index a28ee272..0a730cf6 100644 --- a/src/assets.rs +++ b/src/assets.rs @@ -291,10 +291,11 @@ impl HighlightingAssets { .and_then(|x| x.to_str()) .unwrap_or_default(), ).or_else(|| { - let file_str = file_path.to_str().unwrap_or_default(); - for suffix in IGNORED_SUFFIXES.iter() { - if let Some(stripped_filename) = file_str.strip_suffix(suffix) { - return self.get_extension_syntax(OsStr::new(stripped_filename)); + if let Some(file_str) = file_path.to_str() { + for suffix in IGNORED_SUFFIXES.iter() { + if let Some(stripped_filename) = file_str.strip_suffix(suffix) { + return self.get_extension_syntax(OsStr::new(stripped_filename)); + } } } None