urls: adding redacted-url to mask the password of a URL.
This is particularly useful for logging to avoid accidentally printing passwords in web server logs.master
parent
454f192562
commit
413cc49d3b
|
@ -136,6 +136,10 @@ HELP: relative-url?
|
|||
{ "?" boolean } }
|
||||
{ $description "Tests whether a URL is relative." } ;
|
||||
|
||||
HELP: redacted-url
|
||||
{ $values { "url" url } { "url'" url } }
|
||||
{ $description "Outputs a new URL with the password (if specified) replaced with " { $snippet "xxxxx" } ". This is useful for logging utilities where you want to avoid printing out the password in the logs." } ;
|
||||
|
||||
HELP: secure-protocol?
|
||||
{ $values { "protocol" string } { "?" boolean } }
|
||||
{ $description "Tests if protocol connections must be made with secure sockets (SSL/TLS)." }
|
||||
|
|
|
@ -325,3 +325,7 @@ urls [
|
|||
{ URL" http://www.google.com/" } [
|
||||
URL" http://www.google.com/"
|
||||
] unit-test
|
||||
|
||||
{ URL" https://host:1234/path" } [ URL" https://host:1234/path" redacted-url ] unit-test
|
||||
{ URL" https://user@host:1234/path" } [ URL" https://user@host:1234/path" redacted-url ] unit-test
|
||||
{ URL" https://user:xxxxx@host:1234/path" } [ URL" https://user:password@host:1234/path" redacted-url ] unit-test
|
||||
|
|
|
@ -170,6 +170,9 @@ PRIVATE>
|
|||
[ [ anchor>> ] either? >>anchor ]
|
||||
} 2cleave ;
|
||||
|
||||
: redacted-url ( url -- url' )
|
||||
clone [ "xxxxx" and ] change-password ;
|
||||
|
||||
! Half-baked stuff follows
|
||||
: secure-protocol? ( protocol -- ? )
|
||||
"https" = ;
|
||||
|
|
Loading…
Reference in New Issue