[BUG] T-REPLACE-RX adding extra quotation marks

  • eric1024

    I'm trying to come up with a solution to a problem I'm having (https://sourceforge.net/p/keepass/discussion/329220/thread/1dcd2363/) and am trying to use the T-REPLACE-RX function inside of the Custom Scheme Override.

    My URL for the database entry is as follows (note: quotes around path and executable are necessary due to spaces in program files path):

    putty://"{ENV_PROGRAMFILES_X86}\PuTTY\putty.exe" {USERNAME}@{s:Server}

    I created the scheme override called putty and used the following:


    This should be replacing this:

    C:\Program Files (x86)\PuTTY\putty.exe with

    with this:


    So, the final URL should become:

    cmd://"D:\PuTTY\putty.exe" {USERNAME}@{s:Server}

    However, there seem to be extra spaces being added in somehow. This is the error I get when I try to launch the URL:

    Arguments: "D:\PuTTY\putty.exe""" testuser@testserver
    Cannot start process because a file name has not been provided.

    Notice there are three quotation marks after the putty.exe and one before the D.

    Those extra " symbols are causing the command to be incorrect.

    Also, I initially tried to search for {ENV_PROGRAMFILES_X86} as a whole and replace it with D:\ but that failed. I received this error:

    Cannot start process because a file name has not been provided.

    I'm not sure if this is because this placeholder cannot be used inside of the T-REPLACE-RX function, or if it's because there are single \ characters inside of it.

  • Dominik Reichl
    Dominik Reichl

    This behavior is intended; it's required to correctly encode quotes when {T-REPLACE-RX:...} is used within the parameters of the command line instead of the file.

    You could use the following override for putty://:

    Anyway, I think it would be better to not put the PuTTY path into the URL of the entry and instead specify it in the override only. KeePass contains a built-in override for ssh://, where the override looks like cmd://PuTTY.exe -ssh {USERNAME}@{URL:RMVSCM}. You could create something similar for putty://, specifying the full path to the executable file.

    Best regards,