PATCH: kdelibs/kdecore/kstringhandler.cpp tagURLs() method

Marc Mutz Marc.Mutz at uni-bielefeld.de
Thu Jul 11 20:34:49 BST 2002


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

On Thursday 11 July 2002 13:11, Stephan Hermann wrote:
<snip>
> Well, I changed the regexp in this way:

(cleaned up C-string quoting)
(?:www\.|ftp\.|\w+\://)[\d\w\.]+[:\d]{0,}[/]{0,1}[~/\.-?&=#:_\d\w]{0,}
                                     ^1  ^2 ^3                    ^4
1: wouldn't this be "*"
2: a class with a single char?
3: wouldn't this be "?"
4: see (1)

<snip>
> And at least, the replacement in hrefProtocol I changed, too.
> Not in this way, you described in your last mail, but I used sprintf
> and QString::latin1()
<snip>

How exactly? Since QString::sprintf() assumes %s parameters to be in 
UTF-8, not latin1.

> > No, the safe way is to use operator+:
> > QString url = "<a href=\"" + hrefProtocol + "\">" + href + "</a>";
>
> Hmmm...I like the sprintf way ;) but well, i can change it into your
> solution if you want and disagree with the sprintf way.

Well, I'm not the maintainer of that code, but if you want my advice, 
then you should use operator+, since it's
1. faster (doesn't involve unneccessary QString<->char*<->QString 
   conversions)
2. possibly still more robust.

> I'll make a patch and send it to you directly
<snip>

Why to me? I'm not the maintainer, don't run HEAD, and if you listen to 
Harri and write a test program (e.g. using the examples from the 
URL/URI/URN RFCs), then you should be able to convince yourself of the 
correctness ;-)

IOW: post it here.

Marc

- -- 
Marc Mutz <mutz at kde.org>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)

iD8DBQE9Ld3h3oWD+L2/6DgRAmN4AJ9MQVOW6I2osNUCqrVAwaf7ON0SzQCfRaSo
fbJC3HE084LN7knSvmDsKRY=
=IwJL
-----END PGP SIGNATURE-----





More information about the kde-core-devel mailing list