https://bugs.kde.org/show_bug.cgi?id=422133

            Bug ID: 422133
           Summary: Wrong parameter end detection in useraction expansion
           Product: krusader
           Version: 2.7.2
          Platform: Other
                OS: Linux
            Status: REPORTED
          Severity: normal
          Priority: NOR
         Component: general
          Assignee: krusader-bugs-n...@kde.org
          Reporter: psb...@palant.de
                CC: krusader-bugs-n...@kde.org
  Target Milestone: ---

SUMMARY
I am attempting to create a "copy in same directory" useraction (Shift+F5 in
Total Commander). However, I noticed that placeholder expansion won't work
correctly starting with the third nesting level.

You can see the issue under
https://github.com/KDE/krusader/blob/3766d4106642e15c5970ff51b768271ae4bab3f2/krusader/UserAction/expander.cpp#L1131.
The algorithm deciding whether we are in quotes right now is overly simple and
will fail on the following construct for example:

%a("%b("%c("x","y")")%")%

It will assume that "%b("%c("x" is the first parameter of the %a()% placeholder
(even number of quotation marks) and evaluate it on its own, hence the
"unterminated %" error. The algorithm needs to recognize nested placeholders
properly, not merely quotation marks.

STEPS TO REPRODUCE
1. Create a user action with the following command:

%_Copy("%aCurrent("yes", "no")%", "%_Ask("New file name", "%aCurrent("yes",
"no")%")%")%

2. Run the user action.

OBSERVED RESULT
Error: unterminated % in Expander

EXPECTED RESULT
The useraction runs and allows copying a file. This is what I get if I remove
the second parameter from the second %aCurrent()% placeholder, at the cost of
unnecessary backslashes being added for some file names.

SOFTWARE/OS VERSIONS
Linux: Kubuntu 20.04
KDE Plasma Version: 5.18.5
KDE Frameworks Version: 5.68.0
Qt Version: 5.12.8

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to