[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdelibs/kdecore
From: David Faure <faure () kde ! org>
Date: 2010-12-03 18:52:54
Message-ID: 20101203185254.AF258AC8A5 () svn ! kde ! org
[Download RAW message or body]
SVN commit 1203366 by dfaure:
Fix setEncodedPathAndQuery for the case where the path contains encoded characters.
BUG 258301, I'll backport.
M +2 -2 io/kurl.cpp
M +8 -2 tests/kurltest.cpp
--- trunk/KDE/kdelibs/kdecore/io/kurl.cpp #1203365:1203366
@@ -841,7 +841,7 @@
void KUrl::setEncodedPathAndQuery( const QString& _txt )
{
- int pos = _txt.indexOf( QLatin1Char('?') );
+ const int pos = _txt.indexOf(QLatin1Char('?'));
if ( pos == -1 )
{
setPath( QUrl::fromPercentEncoding( _txt.toLatin1() ) );
@@ -849,7 +849,7 @@
}
else
{
- setPath( QUrl::fromPercentEncoding( _txt.toLatin1() ).left( pos ) );
+ setPath( QUrl::fromPercentEncoding(_txt.toLatin1().left(pos)) );
_setQuery( _txt.right( _txt.length() - pos - 1 ) );
}
}
--- trunk/KDE/kdelibs/kdecore/tests/kurltest.cpp #1203365:1203366
@@ -94,8 +94,8 @@
QCOMPARE( url1.query(), QString("?foo=bar") );
url1.setQuery( "toto=titi&kde=rocks" );
QCOMPARE( url1.query(), QString("?toto=titi&kde=rocks") );
- url1.setQuery( "?kde=rocks&a=b" );
- QCOMPARE( url1.query(), QString("?kde=rocks&a=b") );
+ url1.setQuery( "?kde%20rocks&a=b" ); // must be encoded already, as documented
+ QCOMPARE( url1.query(), QString("?kde%20rocks&a=b") ); // encoded, as documented
url1.setQuery( "?" );
QCOMPARE( url1.query(), QString("?") );
url1.setQuery( "" );
@@ -536,6 +536,12 @@
QCOMPARE( tobi1.query(), QString("?another&query") );
QCOMPARE( tobi1.path(), QString("another/path") ); // without trailing slash
QCOMPARE( tobi1.encodedPathAndQuery(), QString( "another/path?another&query" ) );
+ tobi1.setEncodedPathAndQuery("and%20another%2Bpath%2E?bug=%2B258301&query%2Bword");
+ QCOMPARE( tobi1.query(), QString("?bug=%2B258301&query%2Bword") ); // encoded
+ QCOMPARE( tobi1.queryItem("bug"), QString("+258301") ); // decoded
+ QCOMPARE( tobi1.path(), QString("and another+path.") ); // decoded
+ QCOMPARE( tobi1.encodedPath().constData(), "and%20another+path." ); // from QUrl. \
It only encodes the space. + QCOMPARE( tobi1.encodedPathAndQuery(), QString( \
"and%20another+path.?bug=%2B258301&query%2Bword" ) );
tobi1 = "http://host.net/path/#no-query";
QCOMPARE( tobi1.encodedPathAndQuery(), QString( "/path/" ) );
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic