|
2020-12-31
| ||
| 15:15 | • Ticket [5f923c60b2] URL-Encoding of invalid characters in URL status still O... artifact: 61b1fafbe0 user: kjnash | |
|
2018-04-13
| ||
| 15:08 | • Ticket [5f923c60b2]: 3 changes artifact: e96f15395f user: kjnash | |
|
2015-05-19
| ||
| 15:33 | • New ticket [5f923c60b2]. artifact: ff0c39d0d5 user: anonymous | |
URL-Encoding of invalid characters in URL
Open5f923c60b2f8e9ccbf5702d673c25b09afb460beCreated 12 years agoUpdated 6 years ago
Descriptionplain2015-05-19 15:33:06
::http::geturl doesn't accept this url:
http://127.0.0.1:33543/hub/session/fedc2754-770e-4b3a-9c1e-2fb16d0e0eaf/element/{56dcfe8e-c512-4dbf-a37a-4dbfb6d14b98}/value
I suppose the reason is these characters: "{", "}"
I am developing a selenium library in TCL. And this kind of url's are common. Python automatically converts these illegal characters in path to hexadecimal.
I think that ::http::geturl should also convert all illegal characters in the path.
kjnashplain2018-04-13 15:08:54
There are corner cases that would make this conversion a little awkward - for example if a user has edited a URL in the address bar and added illegal characters, should the command conclude that the entire URL needs conversion and convert any existing "%" again? What if an existing "%" is not followed by a valid hexadecimal code? Should "+" be considered a valid conversion of the space character, or should it be converted to "%2B"? I wonder how the Python library resolves problems like this.
The command http::geturl expects a valid URL. However, the http library could provide commands to encode a URL before passing it to http::geturl.
In the meantime, if you know that the URL path needs encoding, the following code will do it:
package require http
package require uri
proc urlEncodePath {url} {
set splits [uri::split $url]
set encPathList {}
set path [dict get $splits path]
set pathList [split $path /]
foreach el $pathList {
lappend encPathList [http::mapReply $el]
}
set path [join $encPathList /]
dict set splits path $path
uri::join {*}$splits
}
set url http://127.0.0.1:33543/hub/session/fedc2754-770e-4b3a-9c1e-2fb16d0e0eaf/element/{56dcfe8e-c512-4dbf-a37a-4dbfb6d14b98}/value
urlEncodePath $url
- returns -
http://127.0.0.1:33543/hub/session/fedc2754-770e-4b3a-9c1e-2fb16d0e0eaf/element/%7B56dcfe8e-c512-4dbf-a37a-4dbfb6d14b98%7D/value
kjnash Ticket [5f923c60b2]: 4 changes
[History diff]2020-12-31 15:15:54
Log in (anonymous is fine) to add a comment.