tbabej / vit

Placeholder to demostrate issue porting for VIT.
0 stars 0 forks source link

[VT-127] Bad trailing backslash handling in regex search and filter (patch attached) #126

Closed tbabej closed 6 years ago

tbabej commented 6 years ago

Rowan Thorpe on 2015-11-29T13:36:59Z says:

Using the version of Vit pulled from latest git-master, if a search is defined which ends in a backslash the entire vit process exits with exit-code 255, with the following error-message, and leaves the terminal in a jumbled state (invisible cursor, no carriage-return on newlines, etc - obviously the Curses lib doesn't get a chance to cleanup after itself):

Trailing \ in regex m/\/ at /usr/bin/vit line 1898.

and when a trailing backslash is specified in a filter prompt it doesn't kill vit, but the underlying taskwarrior-command outputs error-text which interpolates badly with the Curses prompt:

Filter: \Configuration override rc.defaultwidth:166
                                                   Configuration override rc.defaultheight:0
                                                                                            Configuration override rc._forcecolor:on
Error: task next \: no matches                                                                                                         Top

It seems members of the public can't register at the tasktools stash repo-management tool, so I have instead attached a git-diff of a patch which "Works For Me" (against latest Vit master) for these issues. The regex sanitization can be done in either of two ways (I used only one in the patch of course):

{code:title=either...} if ( $report_lines[$i] =~ /\Q$search_pat\E/i ) { {code}

{code:title=or...} my $quoted_search_pat = quotemeta($search_pat); if ( $report_lines[$i] =~ /$quoted_search_pat/i ) { {code}

tbabej commented 6 years ago

Migrated metadata:

Created: 2015-11-29T13:36:59Z
Modified: 2016-01-11T01:21:41Z
tbabej commented 6 years ago

Scott Kostyshak on 2016-01-10T04:58:13Z says:

Thanks for this clean write-up of this issue and for the patch, Rowan! Here are my thoughts:

tbabej commented 6 years ago

Scott Kostyshak on 2016-01-11T01:21:41Z says:

I've made the fixes at e87c1232 (clean exit so terminal is usable) and 77f2eef0 (do not exit on invalid regex). Can you test the 1.3 branch?

Note also a couple of other similar fixes that you might be interested in. For example, annotations are always quoted now (see bba05dd6), so any character can be used in them.