Menu

KPScript multi-line Notes

Help
Kirill B.
2015-07-13
2018-06-25
  • Kirill B.

    Kirill B. - 2015-07-13

    Hello!

    I'am using KPScript from windows CMD.
    Is it possible to make multi-line Notes when use KPScript -c:AddEntry ?
    I can't find character, that will send "new line".

    I've allready tried:

    1. c:\Program Files (x86)\KeePass Password Safe 2>KPScript.exe -c:addentry Template.kdbx -pw:P@ssw0rd -Title:"Test comment" -username:"tst" -Notes:Line1^Line2
    2. c:\Program Files (x86)\KeePass Password Safe 2>KPScript.exe -c:addentry Template.kdbx -pw:P@ssw0rd -Title:"Test comment" -username:"tst" -Notes:Line1#13#10Line2"
    3. c:\Program Files (x86)\KeePass Password Safe 2>KPScript.exe -c:addentry Template.kdbx -pw:P@ssw0rd -Title:"Test comment" -username:"tst" -Notes:Line1/^Line2"

    And some more options, but didn't reach needed result.

     

    Last edit: Kirill B. 2015-07-13
  • Dominik Reichl

    Dominik Reichl - 2015-07-13

    This was not possible, but I've added it now. The parameters for specifying new field data (for the 'AddEntry' and the 'EditEntry' command) now support escape sequences (e.g. '\n' is replaced by a new-line character).

    Here's the latest KPScript development snapshot for testing:
    http://keepass.info/filepool/KPScript_150713b.zip

    Thanks and best regards,
    Dominik

     
  • Kirill B.

    Kirill B. - 2015-07-13

    I've tested. Works fine. Thanks a lot!

     
  • Guenther Schmitz

    when adding usernames with domain beginning with "t" this also gets escaped
    "domain\testuser"

    could you update KPScript.exe to not escape anything for usernames?

    KR
    Guenther

     
  • Dominik Reichl

    Dominik Reichl - 2016-04-19

    Escape sequences are supported for all fields. Adding an exception for the user name field would be inconsistent and limit functionality (what if you want a Tab in the user name field?); I'm not going to do that.

    If you want to specify domain\testuser as user name, pass domain\\testuser to KPScript, i.e. replace single backslashes by double ones.

    Best regards,
    Dominik

     
  • Kirill B.

    Kirill B. - 2018-06-18

    Hello!
    Necropost)))
    I also got issue with ** \t**:
    I'm using this command line:
    KPScript.exe -c:AddEntry "C:\Safe1.kdbx" "-pw:123" "-Title:symbols test" -UserName:"OU\\user\\test" -Password:test\\this\\symbol
    In case if after \\ going "u" or "s" (for example) - everything works fine, but if after \\ is going "t" i've got troubles.
    Added screenshot with results of this command in GUI.

     

    Last edit: Kirill B. 2018-06-18
  • Dominik Reichl

    Dominik Reichl - 2018-06-18

    This is the intended behavior. If you want a literal \, specify \\.

    Best regards,
    Dominik

     

    Last edit: Dominik Reichl 2018-06-18
  • Kirill B.

    Kirill B. - 2018-06-18

    hm... sourceforge eated double backslash.
    if use OU"double backslash"user"double backslash"test in result i've got (like in screenshot):
    OU\user est

     
  • Kirill B.

    Kirill B. - 2018-06-18

    updated post with commands
    so, the trouble: \\t will bee tab in KPScript, but not \t

     

    Last edit: Kirill B. 2018-06-18
  • Paul

    Paul - 2018-06-18

    I can confirm the behaviour in KPScript 2.39.1. Double slashes before "t" \\t cause a Tab character to be inserted in the entry.
    I've tried single, double and triple slashes, with and without surrounding quotes.

    cheers, Paul

     
  • Dominik Reichl

    Dominik Reichl - 2018-06-18

    I've fixed it. Thanks for reporting this issue!

    Here's the latest KPScript development snapshot for testing:
    https://keepass.info/filepool/KPScript_180618.zip

    Best regards,
    Dominik

     
  • Kirill B.

    Kirill B. - 2018-06-18

    Now working as expected.
    Thank you a lot again!

     
  • Kirill B.

    Kirill B. - 2018-06-22

    Hello again)))
    I think I've found one more issue:
    if password (for example, I think this will be actual for all fields) contains \" I can't find the right way to send these symbols. I've tried:

    • \"
    • \\"
    • \\\"
      I expected that \\\" should work correctly (one backslash for backslash and one for quote), but no.
      If i,m using command:
    kpscript -c:addentry "C:\test.kdbx" -pw:P@ssw0rd -username:test -password:pass\\\"word
    

    in database will be password: pass"word
    Is this true issue or i do something wrong?

     

    Last edit: Kirill B. 2018-06-22
  • Dominik Reichl

    Dominik Reichl - 2018-06-22

    From a KPScript point of view, there's nothing special about quotes; you need to encode them according to the rules of your terminal. On Windows, a quote is typically encoded using 3 quotes (see [1]).

    As discussed, a single backslash must be encoded by 2 backslashes for KPScript. However, note that the terminal may also interpret backslashes, and this may not be consistent or obvious. For example, Cmd.exe doesn't reinterpret 2 backslashes followed by an A (i.e. the target application gets 2 backslashes followed by an A in the command line parameters), but 2 backslashes followed by a quote is changed to 1 backslash only, and 2 backslashes followed by 3 quotes is changed to 1 backslash and 1 quote only (this can be seen with an actual application, not necessarily with built-in commands like ECHO). So, Cmd.exe sometimes treats a backslash as an escape character and sometimes not. In the case when a quote follows, it is treated as escape character.

    Consequently, the encoding of 1 backslash followed by 1 quote for KPScript/Cmd.exe is 4 backslashes followed by 3 quotes.

    Best regards,
    Dominik

    [1] https://msdn.microsoft.com/en-us/library/windows/desktop/bb759784.aspx

     
  • Kirill B.

    Kirill B. - 2018-06-25

    Hello!

    When using other commands (actual for ChangeMasterKey, at least) those rules doesn't work. Terminal is the same.
    Cases:

    1. KPScript '-c:ChangeMasterKey' "C:\Test.kdbx" '-pw:easy' '-newpw:pa"ss\wo\"rd'
      New PW will be: pass\wo"rd
    2. KPScript '-c:ChangeMasterKey' "C:\Test.kdbx" '-pw:easy' '-newpw:pa\"ss\\wo\\\\"""rd'
      New PW will be: pa"ss\\wo\\"rd
    3. KPScript '-c:ChangeMasterKey' "C:\Test.kdbx" '-pw:easy' '-newpw:pa\"ss\wo\\\"rd'
      New PW will be: pa"ss\wo\"rd
    4. KPScript '-c:ChangeMasterKey' "C:\Test.kdbx" '-pw:easy' '-newpw:pa\"ss\wo\\"rd'
      New PW will be: pa"ss\wo\rd
      So i don't understand: are the encoding rules different for different KPScript commands?
      Also, i think i,ve find bug:
      If run from cmd (there is no -pw parameter):
      KPScript.exe '-c:ChangeMasterKey' "C:\Test.kdbx" 'pa\"ss\wo\rd' '-newpw:pa\"ss\wo\\""rd'
      the output will be: OK: Operation completed successfully., but password change do not happens.
     
  • Dominik Reichl

    Dominik Reichl - 2018-06-25

    Cmd.exe doesn't support single quotes ('); you must use double quotes (").

    KPScript typically interprets a backslash as escape character only for entry field value parameters. For the master key changing command, it's not interpreted as escape character (the master password must not contain newlines anyway).

    Best regards,
    Dominik

     

Log in to post a comment.

MongoDB Logo MongoDB