bugGNU nano - Bugs: bug #65301, a plain Replace macro can insert...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #65301: a plain Replace macro can insert unintended text when replayed in regex mode

Submitter:  correctmost <correctmost>
Submitted:  Tue 13 Feb 2024 02:55:34 AM UTC
   
 
Severity:  3 - Normal Status:  Fixed
Assigned to:  bens Open/Closed:  Closed

Thu 02 May 2024 05:37:27 AM UTC, comment #4: 

The fix was released in nano-8.0.  Thanks again for reporting.

Benno Schulenberg <bens>
Group administrator
Wed 14 Feb 2024 10:00:38 AM UTC, comment #3: 

Fixed in git, commit 77d74b5d, by emptying the keystroke buffer upon any kind of error.

(I've also considered the attached patch, that unrecords any unbound keystrokes, but... with some clever rebinding an infinite loop could still be constructed.)

As to making the Case and Regex toggles forgetful, you're probably right: many more people would be affected and annoyed by this change than that there are people that record Search macros and would be convenienced by having the toggles in a predictable state.

(file #55694)

Benno Schulenberg <bens>
Group administrator
Tue 13 Feb 2024 08:20:33 PM UTC, comment #2: 

comment #1:

> The second recipe...  Fantastic!  Disco!  :)


:)

> But... to avoid that entirely, maybe the Regex and Case toggles should be made oneshot toggles?  Just like the Backwards and Multibuffer toggles: only valid during the current menu invocation, and afterward falling back to whatever state was set in the nanorc file.
>


I've gotten used to the search feature being stateful, so that might be an unwelcome behavior change for users.  Other software, like Firefox and VS Code, remembers settings like "Whole Words" and "Match Case" between searches too.

I feel like this edge case doesn't really warrant a change in common search functionality.  The number of people who will be affected by a search change will be much greater than the number of users who will stumble upon this bug/oddity.

correctmost <correctmost>
Tue 13 Feb 2024 04:04:29 PM UTC, comment #1: 

The second recipe...  Fantastic!  Disco!  :)

The attached patch should fix that.  (It's a very old patch, but I never saw the need to apply it.)

The first recipe inserting an "a" is to be expected: the macro was meant to replace a literal "{", when the user then runs it while regular expressions are activated, problems should be expected.

But... to avoid that entirely, maybe the Regex and Case toggles should be made oneshot toggles?  Just like the Backwards and Multibuffer toggles: only valid during the current menu invocation, and afterward falling back to whatever state was set in the nanorc file.


(file #55691)

Benno Schulenberg <bens>
Group administrator
Tue 13 Feb 2024 02:55:34 AM UTC, original submission:  

I tested the following steps with `nano --ignore`.

Steps to reproduce:
01 - Alt + :
02 - Alt + r
03 - Type {
04 - Press enter
05 - Type a
06 - Press enter
07 - Alt + :
08 - Alt + r
09 - Alt + r
10 - Press enter
--> A "Bad regex..." error message is displayed
11 - Alt + ;
--> A spurious "a" is inserted into the buffer


I discovered the above bug while narrowing down this (presumably related) hang:
01 - Alt + :
02 - Alt + r
03 - Type {
04 - Press enter
05 - Alt + ;
--> This is the only addition to the above steps
06 - Type a
07 - Press enter
08 - Alt + :
09 - Alt + r
10 - Alt + r
11 - Press enter
--> A "Bad regex..." error message is displayed
12 - Alt + ;
--> nano hangs


Version: 0e44752ba1474282cbc44a09afefee5c573e4878

correctmost <correctmost>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by bens (Updated the item)
  • -email is unavailable- added by correctmost (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

     

    Follow 6 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2024-05-02 bens Open/ClosedOpen Closed
    2024-02-14 bens Attached File- Added do-not-record-unbound-keystrokes.patch, #55694
        StatusNone Fixed
        Summarynano inserts spurious character when replaying replace macro after bad-regex search a plain Replace macro can insert unintended text when replayed in regex mode
    2024-02-13 bens Attached File- Added 0001-input-flush-the-keyboard-buffer-upon-any-kind-of-err.patch, #55691
        Assigned toNone bens

    Back to the top

    Powered by Savane 3.13-4b4b.
    Corresponding source code