From f51f5fe202efaddd394a311752f3e5beee7119a0 Mon Sep 17 00:00:00 2001 From: Benjamin Sago Date: Tue, 2 May 2017 08:46:43 +0100 Subject: [PATCH] Also escape characters in broken symlinks --- Vagrantfile | 3 +++ src/output/file_name.rs | 2 +- xtests/file_names_R | 2 +- xtests/file_names_T | 2 ++ 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Vagrantfile b/Vagrantfile index 60477bc..c412e8a 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -176,9 +176,12 @@ Vagrant.configure(2) do |config| echo -ne "#{test_dir}/file-names/new-line-dir: [\\n]" | xargs -0 mkdir echo -ne "#{test_dir}/file-names/new-line-dir: [\\n]/subfile" | xargs -0 touch echo -ne "#{test_dir}/file-names/new-line-dir: [\\n]/another: [\\n]" | xargs -0 touch + echo -ne "#{test_dir}/file-names/new-line-dir: [\\n]/broken" | xargs -0 touch mkdir "#{test_dir}/file-names/links" ln -s "#{test_dir}/file-names/new-line-dir"*/* "#{test_dir}/file-names/links" + + echo -ne "#{test_dir}/file-names/new-line-dir: [\\n]/broken" | xargs -0 rm EOF diff --git a/src/output/file_name.rs b/src/output/file_name.rs index f48b952..939f841 100644 --- a/src/output/file_name.rs +++ b/src/output/file_name.rs @@ -59,7 +59,7 @@ impl<'a, 'dir> FileName<'a, 'dir> { bits.push(Style::default().paint(" ")); bits.push(self.colours.broken_arrow.paint("->")); bits.push(Style::default().paint(" ")); - bits.push(self.colours.broken_filename.paint(broken_path.display().to_string())); + escape(broken_path.display().to_string(), &mut bits, self.colours.broken_filename, self.colours.control_char.underline()); }, FileTarget::Err(_) => { diff --git a/xtests/file_names_R b/xtests/file_names_R index 75cb640..7b7c9fe 100644 --- a/xtests/file_names_R +++ b/xtests/file_names_R @@ -6,7 +6,7 @@ emoji: [๐Ÿ†’] invalid-utf8-4: [๏ฟฝ(๏ฟฝ(] utf-8: pรขtรฉ escape: [\u{1b}] links vertical-tab: [\u{b}] /testcases/file-names/links: -another: [\n] subfile +another: [\n] broken subfile /testcases/file-names/new-line-dir: [\n]: another: [\n] subfile diff --git a/xtests/file_names_T b/xtests/file_names_T index f185266..528e4b3 100644 --- a/xtests/file_names_T +++ b/xtests/file_names_T @@ -16,6 +16,8 @@ โ”‚ โ””โ”€โ”€  โ”œโ”€โ”€ links โ”‚ โ”œโ”€โ”€ another: [\n] -> /testcases/file-names/new-line-dir: [\n]/another: [\n] +โ”‚ โ”œโ”€โ”€ broken -> /testcases/file-names/new-line-dir: [\n]/broken +โ”‚ โ”‚ โ””โ”€โ”€  โ”‚ โ””โ”€โ”€ subfile -> /testcases/file-names/new-line-dir: [\n]/subfile โ”œโ”€โ”€ new-line-dir: [\n] โ”‚ โ”œโ”€โ”€ another: [\n]