Ver Fonte

Also escape characters in broken symlinks

Benjamin Sago há 8 anos atrás
pai
commit
f51f5fe202
4 ficheiros alterados com 7 adições e 2 exclusões
  1. 3 0
      Vagrantfile
  2. 1 1
      src/output/file_name.rs
  3. 1 1
      xtests/file_names_R
  4. 2 0
      xtests/file_names_T

+ 3 - 0
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
 
 

+ 1 - 1
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(_) => {

+ 1 - 1
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

+ 2 - 0
xtests/file_names_T

@@ -16,6 +16,8 @@
 │  └── <Error: path somehow contained a NUL?>
 ├── links
 │  ├── another: [\n] -> /testcases/file-names/new-line-dir: [\n]/another: [\n]
+│  ├── broken -> /testcases/file-names/new-line-dir: [\n]/broken
+│  │  └── <No such file or directory (os error 2)>
 │  └── subfile -> /testcases/file-names/new-line-dir: [\n]/subfile
 ├── new-line-dir: [\n]
 │  ├── another: [\n]