KURL construction bug?

Waldo Bastian bastian at kde.org
Fri Feb 27 21:21:05 GMT 2004


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Fri February 27 2004 22:12, Andras Mantia wrote:
> Hi,
>
>  I've just noticed a strange (for me) behavior in the KURL. I'd like to
> construct a KURL from a string which is in a form of
> "/path/filename#reference". If I use:
> KURL url;
> url.setPath(string);
>
> the url will have m_strPath = "/path/filename#reference" and the
> m_strRef_encoded member empty. And the KHTML part will fail on opening the
> file and going to the reference.
>
> If I use KURL url("file:" + string) everything works correctly and
> m_strRef_encoded = "reference", m_strPath = "/path/filename".
>
> Is that the desired behavior and I misunderstood the documentation or this
> is a bug in setPath() ?

That's desired behavior.

You have to realize that a file path and an URL are not the same thing. For 
example the path "/directory/some file" will result in the URL 
"file:/directory/some%20file". You say you have a string in the form of 
"/path/filename#reference" and it seems that the #reference part is not 
supposed the part of the filename, so I guess that you want this to be 
treated as a (rather ill formed) URL. In that case you can just assign the 
string to KURL:
	KURL url(string);

Cheers,
Waldo
- -- 
bastian at kde.org -=|[ SUSE, The Linux Desktop Experts ]|=- bastian at suse.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (GNU/Linux)

iD8DBQFAP7TCN4pvrENfboIRAmuuAJ40l7ChNMVxsZSCJx+unaYoEQp5EQCeJ0j/
ufiZS00im9xSXFKzpNGdIo0=
=2eKs
-----END PGP SIGNATURE-----




More information about the kde-core-devel mailing list