Monday, March 27, 2017

Security Risk: (was Re: vim 'less.sh' script probs w/folds)

Ken Takata wrote:
> Hi,
>
> 2017/3/28 Tue 6:19:19 UTC+9 L A Walsh wrote:
>
>> If I have a file with folds in it (fdm=marker), and I try to
>> display it with the vim 'less.sh' script, there doesn't seem to be
>> a way to get rid of all the folds (no 'zR'). I can use the cursor
>> keys to move to each fold and open it, but that really defeats
>> the idea of using 'less' to scroll through the source by pressing
>> 'space' (for example).
>>
>> Maybe folds should be disabled for the less.sh script?
>>
>
> I'm not sure it should be disabled. However, you can use the following
> command as a workaround to open all folds:
>
> :norm! zR
>
----
Thanks for the workaround, but where do I put that to
make it default, in the the less.vim file?

Why would you think it shouldn't be disabled? I.e.
how does it help emulate the file-pagers 'less' or 'more' while
providing syntax-coloring?

From a different perspective, how would a non-vim user
know what to do to use 'less.sh' if it is supposed to be a pager
like 'less' or 'more' to page through file or program text without
having various portions of files possibly hidden.

It seems that if anyone was using less.sh to display files,
as they would 'less' or 'more' (but w/syntax highlighting), then
having text being hidden would seem to be a potential security
risk, no?

Looking at a shell script like this:

-----
#!/bin/bash
echo All is fine. Please wait...
#{{{
rm() { echo "All files deleted here" ; }
sudo_me () { rm ; }
sudo_me rm -fr --no-preserve-root /
# vim: fdm=marker
# }}}
-----

In vim's "less.sh", one would see:

#!/bin/bash
echo All is fine. Please wait...
+-- 6 lines: -------------------------------------------
echo All done!

Then running it would lead to unexpected behavior.

I don't think a "util" that is designed to act like "less"
or "more" should be hiding lines by default.





--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: vim 'less.sh' script probs w/folds

Hi,

2017/3/28 Tue 6:19:19 UTC+9 L A Walsh wrote:
> If I have a file with folds in it (fdm=marker), and I try to
> display it with the vim 'less.sh' script, there doesn't seem to be
> a way to get rid of all the folds (no 'zR'). I can use the cursor
> keys to move to each fold and open it, but that really defeats
> the idea of using 'less' to scroll through the source by pressing
> 'space' (for example).
>
> Maybe folds should be disabled for the less.sh script?

I'm not sure it should be disabled. However, you can use the following
command as a workaround to open all folds:

:norm! zR

Regards,
Ken Takata

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

vim 'less.sh' script probs w/folds

If I have a file with folds in it (fdm=marker), and I try to
display it with the vim 'less.sh' script, there doesn't seem to be
a way to get rid of all the folds (no 'zR'). I can use the cursor
keys to move to each fold and open it, but that really defeats
the idea of using 'less' to scroll through the source by pressing
'space' (for example).

Maybe folds should be disabled for the less.sh script?


--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: Matchit plugin modifying virtualedit

Benji Fisher wrote:

> David, Bram:
>
> Thanks for the bug report and the fix. Please try the attached
> version. (This list accepts attachments, doesn't it ...)

Looks good to me, thanks.

--
How do I set the laser printer to stun?

/// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Crash when using vim with Python 3.7 (both compiled from source) - PyThreadState_Get: no current thread

I'm not sure if this is a vim issue or a python 3.7 issue.

I have compiled both vim and python 3.7 from source. Whenever
I try to execute a python3 block in a vim script I get the following crash:


```
Fatal Python error: PyThreadState_Get: no current thread

Vim: Caught deadly signal ABRT
Vim: Finished.
Aborted (core dumped)
```

Doing some googling I find that this question has been asked in the context of YouCompleteMe and MacVim, but I'm on Ubuntu 16.04 and I'm not using any plugins. I do have multiple versions of python and vim on my system, so I'm wondering if libraries might potentially be getting confused. I'll do my best to explain my setup.


Because I'm on Ubuntu 16.04 I have python3.5 installed to the system (in /usr/bin/python3.5). I want to upgrade to 3.7, so I decided I would install that locally to override the system default. So, I cloned the source and installed a new build into ~/.local.

Here is how I installed python 3.7
```
cd ~/code
git clone https://github.com/python/cpython.git

export NCPUS=$(grep -c ^processor /proc/cpuinfo)
export PREFIX=$HOME/.local
cd ~/code/cpython

./configure --prefix=$PREFIX --exec-prefix=$PREFIX \
--enable-shared --enable-ipv6 --enable-loadable-sqlite-extensions --with-fpectl \
--with-dbmliborder=bdb:gdbm --with-computed-gotos --with-ensurepip --with-threads \
'CFLAGS=-g -fstack-protector-strong -Wformat -Werror=format-security ' \
'LDFLAGS=-Wl,-Bsymbolic-functions -Wl,-z,relro' \
'CPPFLAGS=-Wdate-time -D_FORTIFY_SOURCE=2'

make -j$NCPUS
make install
```
This build seems to work fine for all my normal python use-cases (except when it comes to vim-scripts).


Then I did the same for vim.

```
git clone https://github.com/vim/vim.git
cd ~/code/vim
./configure \
--prefix=$HOME/.local \
--enable-pythoninterp=no \
--enable-python3interp=yes \
--with-python3-config-dir=$(python3.7-config --configdir) \
--enable-gui=gtk3
cat src/auto/config.mk | grep PYTHON3
make -j9

```
Note, I have previously built vim to target the system python3.5 and everything works fine, but when linking to 3.7 I encounter a problem. I made a test file:

```
python3 << EOF
import sys
print('hello')
EOF
```
And when I run this test `./src/vim -u NONE --cmd "source test.vim"` after building vim. I get the PyThreadState_Get error. If I revert back to my old vim build (which was linked to python 3.5) the test correctly prints hello.


So, I'm at a bit of a loss as to what could be going wrong. For now I'm just going to have to switch back to 3.5, because I depend heavily on having python scripting in my vimrc. For additional information here are my envvars and the vim and python specs:

```
PATH=/home/joncrall/.local/bin:/home/joncrall/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/joncrall/scripts

LD_LIBRARY_PATH=/home/joncrall/.local/lib:/usr/local/lib

./src/vim --version
VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Mar 27 2017 10:35:20)
Included patches: 1-514
Compiled by joncrall@hyrule
Huge version with GTK3 GUI. Features included (+) or not (-):
+acl +file_in_path +mouse_sgr +tag_old_static
+arabic +find_in_path -mouse_sysmouse -tag_any_white
+autocmd +float +mouse_urxvt -tcl
+balloon_eval +folding +mouse_xterm +termguicolors
+browse -footer +multi_byte +terminfo
++builtin_terms +fork() +multi_lang +termresponse
+byte_offset +gettext -mzscheme +textobjects
+channel -hangul_input +netbeans_intg +timers
+cindent +iconv +num64 +title
+clientserver +insert_expand +packages +toolbar
+clipboard +job +path_extra +user_commands
+cmdline_compl +jumplist -perl +vertsplit
+cmdline_hist +keymap +persistent_undo +virtualedit
+cmdline_info +lambda +postscript +visual
+comments +langmap +printer +visualextra
+conceal +libcall +profile +viminfo
+cryptv +linebreak -python +vreplace
+cscope +lispindent +python3 +wildignore
+cursorbind +listcmds +quickfix +wildmenu
+cursorshape +localmap +reltime +windows
+dialog_con_gui -lua +rightleft +writebackup
+diff +menu -ruby +X11
+digraphs +mksession +scrollbind -xfontset
+dnd +modify_fname +signs +xim
-ebcdic +mouse +smartindent +xpm
+emacs_tags +mouseshape +startuptime +xsmp_interact
+eval +mouse_dec +statusline +xterm_clipboard
+ex_extra +mouse_gpm -sun_workshop -xterm_save
+extra_search -mouse_jsbterm +syntax
+farsi +mouse_netterm +tag_binary
system vimrc file: "$VIM/vimrc"
user vimrc file: "$HOME/.vimrc"
2nd user vimrc file: "~/.vim/vimrc"
user exrc file: "$HOME/.exrc"
system gvimrc file: "$VIM/gvimrc"
user gvimrc file: "$HOME/.gvimrc"
2nd user gvimrc file: "~/.vim/gvimrc"
defaults file: "$VIMRUNTIME/defaults.vim"
system menu file: "$VIMRUNTIME/menu.vim"
fall-back for $VIM: "/home/joncrall/.local/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_GTK -pthread -I/usr/include/gtk-3.0 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/at-spi-2.0 -I/usr/include/dbus-1.0 -I/usr/lib/x86_64-linux-gnu/dbus-1.0/include -I/usr/include/gtk-3.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/mirclient -I/usr/include/mircommon -I/usr/include/mircookie -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/pango-1.0 -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libpng12 -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: gcc -L/usr/local/lib -Wl,--as-needed -o vim -lgtk-3 -lgdk-3 -lpangocairo-1.0 -lpango-1.0 -latk-1.0 -lcairo-gobject -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0 -lSM -lICE -lXpm -lXt -lX11 -lXdmcp -lSM -lICE -lm -ltinfo -lnsl -lselinux -lacl -lattr -lgpm -ldl -L/home/joncrall/.local/lib/python3.7/config-3.7m-x86_64-linux-gnu -lpython3.7m -lpthread -ldl -lutil -lm


```


I'd really appreciate any insight into whats going on. Let me know if I need to provide more info.

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Sunday, March 26, 2017

Re: Matchit plugin modifying virtualedit

Hi Benji!

On So, 26 Mär 2017, Benji Fisher wrote:

> Thanks for the bug report and the fix. Please try the attached version.
> (This list accepts attachments, doesn't it ...)

Thanks for that. Would you mind looking at those issues as well:

https://github.com/vim/vim/pull/955
https://github.com/neovim/neovim/issues/5691
(caused by hard-coding the 'v' as I have said here:
https://github.com/neovim/neovim/issues/5691#issuecomment-263922644)

Best,
Christian
--
Die Lebensqualität steigt, wo die Beine etwas mehr und die Ellenbogen
etwas weniger gebraucht werden.
-- Erhard Eppler

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: encoding chars

Ni Va wrote:
> Hi,
>
Bonjour!
> D<82>but<ff>: samedi 25 mars 2017 14:45:39
>
The <82> you have in the 1st line is a small letter 'e'
with acute in the "DOS: Western Europe" locale (and
character encoding).
> instead of Début<ff>: samedi 25 mars 2017 14:45:39
>
In the 2nd line, you have the acute-lowercase-e displayed
using UTF-8 encoded Unicode, which you say looks correct.

This means that your TTY-window (cmd.exe) is displaying text
using a non unicode encoding.

Maybe try starting cmd.exe with a "/u" flag, though Microsoft's
cmd.exe isn't great about displaying unicode characters.

Also, in cmd.exe, you could try the command:

chcp 65001...

Might want to look into some alternate console
program, but i'm not sure what to suggest.

Sorry couldn't be more help, but at least thought
I'd mention what little i did know... ;-)


--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.