Hi Stephane,
I was looking at some of the Pharo code and discovered a gap in the logic. (But is is perhaps a gap in my understanding of the underlying specification.) The same error may well be found in 3.0 (I have not checked).
Try the following.
UrlTest>>#testUsernameEncoded
WithoutPassword2
"Sometimes, weird usernames or passwords are necessary in applications, and, thus, we might receive them in a Url. The @ and the : are the kind of critical ones."
#( "('user' 'pword' 'host' port 'path')"
('St�phane rst P�ckler' '' 'cottbus.brandenburg' 80 'mein/Zuhause')
('Jeannde.d''Arc' '' 'orleans' 8080 'une/deux/trois')
('HaXor@roxor:fnac' '' 'cbase' 42 'do/not_try')
) do: [:urlParts | |theUrl|
theUrl := (
'http://{1}@{3}:{4}/{5}' format: {
(urlParts at: 1) encodeForHTTP.
(urlParts at: 2) encodeForHTTP.
urlParts at: 3. urlParts at: 4. urlParts at: 5.
}) asUrl.
self assert: (theUrl schemeName = 'http').
self assert: (theUrl username = (urlParts at: 1)).
self assert: (theUrl password = (urlParts at: 2)).
self assert: (theUrl authority = (urlParts at: 3)).
self assert: (theUrl port = (urlParts at: 4)).
self assert: theUrl path first = ((urlParts at: 5) copyUpTo: $/ )]