Re:The Invisible JavaScript Backdoor
by fatheart on Wednesday November 10, 2021 @10:34AM
(#29175749)
After seeing this thread I added the following to my vimrc:
highlight link NonASCII Error
autocmd Syntax * :syntax match NonASCII "[^\d0-\d127]"
Obviously haven't been using it long, and I'm not confident enough in my vim knowledge to vouch for its correctness, but it works in the limited amount of scenarios I tested so far.Sure:
fun! HighlightNonAscii()
if &ft =~ 'markdown\|text'
return
endif
syntax match nonascii "[^\x00-\x7F]"
highlight nonascii guibg=#ff2232 guifg=#000000
endfun
autocmd BufEnter * call HighlightNonAscii()
Your version might depend on your frontend (gui, terminal...). And you might want to filter more file types.
I thought this was default but just realised it only does the <FFFF> thing when there is no printable glyph available.
Allowing printable unicode in strings seems like a nice balance if it can be done reliably.