[Qt-interest] Problem using URL with special characters
Atlant Schmidt
aschmidt at dekaresearch.com
Mon Aug 29 13:22:41 CEST 2011
Thiago:
If:
1. It's "the same mistake that everyone does" and
2. "QUrl's ... constructor is unusable"
It's not really "everyone's mistake"; it's a bug in Qt.
Now if the design of QUrl can't be fixed so its constructor
must remain unusable, maybe Qt needs to replace the construc-
tor with the printing of an error message and an ASSERT(false)
or some other construct that will prevent "everyone" from
blundering into this design problem?
Atlant
-----Original Message-----
From: qt-interest-bounces+aschmidt=dekaresearch.com at qt.nokia.com [mailto:qt-interest-bounces+aschmidt=dekaresearch.com at qt.nokia.com] On Behalf Of Thiago Macieira
Sent: Friday, August 26, 2011 18:38
To: qt-interest at qt.nokia.com
Subject: Re: [Qt-interest] Problem using URL with special characters
On Friday, 26 de August de 2011 16:07:26 kent williams wrote:
> 'https://predict-hd.net/xnat/REST/projects/FMRI_HD_024/subjects/0252/experim
> ents/45602/scans/2?xnat:mrScanData/parameters/addParam[name%3DReviewed]/addf
> ield=Yes'
> So I'm guessing the problem is that that the QUrl encoding is garbling
> my URL. If I call toEncoded() I get this:
>
> https://predict-hd.net/xnat/REST/projects/FMRI_HD_024/subjects/0252/experime
> nts/45602/scans/2?xnat:mrScanData/parameters/addParam%5Bname%253DReviewed%5D
> /addfield=Yes
>
> In particular it's replacing my square brackets, and garbling the %3D
> (encoded '=')
>
> I'm new to using Qt in this way and I'm baffled as to how to get to
> NOT screw up my URL. Any ideas?
Note that the encoding of the brackets as %5B and %5D is perfectly correct.
Focus on what's wrong: your original URL had %3D and the encoded form you
produced says %253D.
My guess is that you made the same mistake that everyone does: due to a flaw in
QUrl's design, it's constructor is unusable. Please add this to your code:
#define QT_NO_URL_CAST_FROM_STRING
And make sure you never call the QUrl constructor.
You want to use QUrl::formEncoded.
--
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
Software Architect - Intel Open Source Technology Center
PGP/GPG: 0x6EF45358; fingerprint:
E067 918B B660 DBD1 105C 966C 33F5 F005 6EF4 5358
This e-mail and the information, including any attachments, it contains are intended to be a confidential communication only to the person or entity to whom it is addressed and may contain information that is privileged. If the reader of this message is not the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please immediately notify the sender and destroy the original message.
Thank you.
Please consider the environment before printing this email.
More information about the Qt-interest-old
mailing list