Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#1877 GetOverrideForUrl(), more flexible override selection

KeePass
open
nobody
None
5
2014-09-01
2014-05-26
sambowry
No

Please allow reordering Custom URL Overrides (alt up/down) and change override selection logic!

It may give us more built-in flexibility by using more than one URL Override of a protocol to handle different accounts (and optional command line parameters).

field examples:

ssh://account@host   # username/password stored in a separate entry named 'account'
ssh://user:pass@host # unique username/password stored in the field
ssh://user@host      # only username stored in the field (public key login)
ssh://host           # username/password stored in the entry standard fields

The following SSH protocol overrides handles the different cases:

cmd://ssh.exe {BASE:HOST} -l {REF:U@T:{BASE:USERINFO}} -pw {REF:P@T:{BASE:USERINFO}}
cmd://ssh.exe {BASE:HOST} -l {REF:U@T:{BASE:USERINFO}}
cmd://ssh.exe {BASE:HOST} -l {BASE:USERNAME} -pw {BASE:PASSWORD}
cmd://ssh.exe {BASE:HOST} -l {BASE:USERNAME}
cmd://ssh.exe {BASE:HOST} -l {USERNAME} -pw {PASSWORD}
cmd://ssh.exe {BASE:HOST} -l {USERNAME}

GetOverrideForUrl() may test the overrides up-down. The right matching override found if no empty/nonexistent field was touched during compile().

Backward compatibility may provide by the rule that the last entry is always matching.

Discussion

  • sambowry
    sambowry
    2014-06-01

    Two {T-REPLACE-RX:...} are able to emulate an if-then-else like structure:

    if not empty( _TEXT_ )
      _THEN_
    else
      _ELSE_
    
    {T-REPLACE-RX:!{T-REPLACE-RX:/1:_TEXT_/\A1:.+\z/_THEN_/}!\A1:\z!_ELSE_!}
    

    So workaround for the missing override selection is exists by selecting the right format with this if-then-else construct. The following example tries to extend an ssh url with username/password from various places:

    ssh://{T-REPLACE-RX:3{T-REPLACE-RX:21:{BASE:PASSWORD}2\A1:.+\z2{BASE:USERNAME}:{BASE:PASSWORD}2}3\A1:\z3{T-REPLACE-RX:6{T-REPLACE-RX:54:{BASE:USERINFO}5\A4:.+\z5{REF:U@T:{BASE:USERINFO}}:{REF:P@T:{BASE:USERINFO}}5}6\A4:\z6{USERNAME}:{PASSWORD}6}3}@{BASE:HOST}