[vim/vim] It shows garbled characters when I open a "*.tar.gz" file (#6425)

110 views
Skip to first unread message

RisingooSun

unread,
Jul 9, 2020, 9:52:36 AM7/9/20
to vim/vim, Subscribed

Hi guys
It shows garbled characters when I open a "*.tar.gz" file, which is compressed from the file with “error” in the name.

For example:

    [root@192-168-100-100 ~]# touch error_test.log

    [root@192-168-100-100 ~]# tar -zcvf test.tar.gz error_test.log 

     error_test.log

    [root@192-168-100-100 ~]# vim test.tar.gz

image

    My os version:  CentOS Linux release 7.5.1804 (Core)

    My vim version:   vim-enhanced-7.4.160-4.el7.x86_64



Wating for your help

Thank you


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or unsubscribe.

Christian Brabandt

unread,
Jul 9, 2020, 10:35:53 AM7/9/20
to vim/vim, Subscribed

You have a very old version of Vim installed. Nevertheless, I can reproduce the problem in tar.vim.

The problem is, the tar.vim plugin checks if the last line matches warning or error or a few other keywords and if it does, it aborts.

If we make the regex a bit more strict and also require to have it match a space (after all an error message should contain some spaces to be more readable and unix files are very unlikely to contain spaces) we can work around this:

diff --git a/runtime/autoload/tar.vim b/runtime/autoload/tar.vim
index 9f9609434..56d125cf6 100644
--- a/runtime/autoload/tar.vim
+++ b/runtime/autoload/tar.vim
@@ -204,7 +204,12 @@ fun! tar#Browse(tarfile)
 "   call Dret("tar#Browse : a:tarfile<".a:tarfile.">")
    return
   endif
-  if line("$") == curlast || ( line("$") == (curlast + 1) && getline("$") =~# '\c\%(warning\|error\|inappropriate\|unrecognized\)')
+  " If there was an error message, the last line probably matches some keywords but
+  " should also contain whitespace for readability. Make sure not to match a
+  " filename that contains the keyword (error/warning/unrecognized/inappropriate, etc)
+  if line("$") == curlast || ( line("$") == (curlast + 1) &&
+        \ getline("$") =~# '\c\<\%(warning\|error\|inappropriate\|unrecognized\)\>' &&
+        \ getline("$") =~  '\s' )
    redraw!
    echohl WarningMsg | echo "***warning*** (tar#Browse) ".a:tarfile." doesn't appear to be a tar file" | echohl None
    keepj sil! %d

cc Charles, the maintainer: @cecamp

RisingooSun

unread,
Jul 9, 2020, 12:30:20 PM7/9/20
to vim/vim, Subscribed

Nice work, my buddy! I modified tar.vim according to your patch and it worked. Now It displays normally. Thank you for your help.
image

buweilv

unread,
Jul 13, 2020, 2:19:27 AM7/13/20
to vim/vim, Subscribed

You have a very old version of Vim installed. Nevertheless, I can reproduce the problem in tar.vim.

The problem is, the tar.vim plugin checks if the last line matches warning or error or a few other keywords and if it does, it aborts.

If we make the regex a bit more strict and also require to have it match a space (after all an error message should contain some spaces to be more readable and unix files are very unlikely to contain spaces) we can work around this:

diff --git a/runtime/autoload/tar.vim b/runtime/autoload/tar.vim
index 9f9609434..56d125cf6 100644
--- a/runtime/autoload/tar.vim
+++ b/runtime/autoload/tar.vim
@@ -204,7 +204,12 @@ fun! tar#Browse(tarfile)
 "   call Dret("tar#Browse : a:tarfile<".a:tarfile.">")
    return
   endif
-  if line("$") == curlast || ( line("$") == (curlast + 1) && getline("$") =~# '\c\%(warning\|error\|inappropriate\|unrecognized\)')
+  " If there was an error message, the last line probably matches some keywords but
+  " should also contain whitespace for readability. Make sure not to match a
+  " filename that contains the keyword (error/warning/unrecognized/inappropriate, etc)
+  if line("$") == curlast || ( line("$") == (curlast + 1) &&
+        \ getline("$") =~# '\c\<\%(warning\|error\|inappropriate\|unrecognized\)\>' &&
+        \ getline("$") =~  '\s' )
    redraw!
    echohl WarningMsg | echo "***warning*** (tar#Browse) ".a:tarfile." doesn't appear to be a tar file" | echohl None
    keepj sil! %d

cc Charles, the maintainer: @cecamp

@cecamp
Hi cecmap, is this issue a problem, would chrisbra's patch be merged into mainline?

cecamp

unread,
Jul 13, 2020, 2:53:32 PM7/13/20
to vim/vim, Subscribed

Thank you, Christian -- I'll include it. Eventually it will get to Bram...

cecamp

unread,
Jul 13, 2020, 2:53:38 PM7/13/20
to vim/vim, Subscribed

Closed #6425.

刘大波

unread,
Jan 30, 2022, 4:10:11 AM1/30/22
to vim/vim, Subscribed

When will this be resolved? thanks!


Reply to this email directly, view it on GitHub, or unsubscribe.

Triage notifications on the go with GitHub Mobile for iOS or Android.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/6425/1025101158@github.com>

code-Oct

unread,
Jan 5, 2023, 9:56:35 PM1/5/23
to vim/vim, Subscribed

@brammool Why is this solution not intergrated into the master?Are there any other reasons?thanks


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/6425/1373077563@github.com>

Bram Moolenaar

unread,
Jan 6, 2023, 7:49:53 AM1/6/23
to vim/vim, Subscribed

It looks like version 33 of the tar plugin wasn't finished. You can find the unfinished version on Charles website.
@cecamp can you send me the version to included?


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/6425/1373580953@github.com>

code-Oct

unread,
Jan 8, 2023, 8:33:30 PM1/8/23
to vim/vim, Subscribed

It looks like version 33 of the tar plugin wasn't finished. You can find the unfinished version on Charles website.

Thank you for your response!


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/6425/1375001750@github.com>

Reply all
Reply to author
Forward
0 new messages