how Windows browsers encode URL [Re: why the % cruft?]

Waldo Bastian bastian at kde.org
Fri Jul 12 01:46:27 BST 2002


On Wednesday 10 July 2002 02:05 pm, Hetz Ben Hamo wrote:
> I did - here it is again:
>
> http://chat.tapuz.co.il/newchat/main.asp?regUser=no&shower=1&room=30%20ôìåñ
>%20àéëåúé&nick=fasdfasd This URL lets you go into a Java hebrew based chat.
>
> With MSIE (and suprisingly Netscape 4.x) - the gybrish stuff is being feed
> into the server as parameters which room.
>
> the fasdfasd stuff is my test to put a nick name. if I put a hebrew nick
> the chat java client will get it as "????????" in konqueror. Actually if
> you'll try this URL on konqueror with Java enabled, you'll get into the
> chat to a room named "30 ????? ??????" - the ? should be of course hebrew
> letters ;)

The problem seems to be related to the fact that the javascript construct 
"location.href = ...." fails to pass on the encoding.

E.g. there is:
KURL KHTMLPart::completeURL( const QString &url )
{
  if ( !d->m_doc ) return url;

  if (d->m_decoder)
    return KURL(d->m_doc->completeURL(url), d->m_decoder->codec()->mibEnum());

  return KURL( d->m_doc->completeURL( url ) );
}
which correctly informs KURL about the encoding but which is too late because 
m_doc->completeURL() has already ruined it.

In order to do it right, m_doc should know about the codec so that 
m_doc->completeURL( url ) can do the right thing itself. Can I add that?

The other option is to change all occurences of:
       KHTMLPart* p = Window::retrieveActive(exec)->m_part;
        if ( p )
          url = p->htmlDocument().completeURL(str).string();

in khtml/ecma into something like:
       KHTMLPart* p = Window::retrieveActive(exec)->m_part;
        if ( p )
          url = p->completeURL(str);

And then change KHTMLPart::completeURL() to:

  if (d->m_decoder)
    return KURL(d->m_doc->baseURL(), url, d->m_decoder->codec()->mibEnum());

But then everyone else who still uses htmDocument().completeURL() will run 
into similar problems.

(And after that the only thing needed is a patch for KURL so that KURL::url() 
returns ascii-only URLs)

Cheers,
Waldo
-- 
bastian at kde.org  |   SuSE Labs KDE Developer  |  bastian at suse.com





More information about the kfm-devel mailing list