[Psi-Devel] Rev 1064 : Added TextUtil::escape() and TextUtil::unescape()

Michail Pishchagin mblsha at gmail.com
Wed Feb 27 20:25:47 PST 2008


On 27.02.2008, at 14:40, Kevin Smith wrote:

> On Wed, Feb 27, 2008 at 5:19 AM, dev <dev.akhawe at gmail.com> wrote:
>> In a recent patch to textutil.cpp , textshell used Qt::escape instead
>> of using the functions present in the TextUtil.cpp. Shouldn't that be
>> preferred?
>
> mblsha?


Concerning this is the mentioned textshell patch:

> @@ -349,6 +353,8 @@
>  				continue;
>  			}
>  			href += link;
> +			// attributes need to be encoded too.
> +			href = Qt::escape(href);
>  			href = linkify_htmlsafe(href);
>  			//printf("link: [%s], href=[%s]\n", link.latin1(), href.latin1());
>  			linked = QString("<a href=\"%1\">").arg(href) + Qt::escape(link)  
> + "</a>" + Qt::escape(pre.mid(cutoff));
>

Well, it's kinda weird. Previously the linkify_htmlsafe() was used,  
and it escapes everything TextUtil::escape() does, with only exception  
of &. TextUtil::escape() escapes everything Qt::escape() does, plus  
the quotation mark. Qt::escape() with conjunction of  
linkify_htmlsafe() escape more chars than TextUtil::escape() does.

And there's a stupid double-escape problem with TextUtil::escape(),  
shame on me.

-Michail


More information about the Psi-Devel mailing list