[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [kdelibs/KDE/4.11] kdecore/tests: Test to ensure that when setting an encoded plus sign '+' in query
From:       Andrea Iacovitti <aiacovitti () libero ! it>
Date:       2013-08-31 23:41:39
Message-ID: E1VFunT-00076w-4D () scm ! kde ! org
[Download RAW message or body]

Git commit e8b29e145745c008ecc893e3f9ce00f291884184 by Andrea Iacovitti.
Committed on 31/08/2013 at 23:40.
Pushed by aiacovitti into branch 'KDE/4.11'.

Test to ensure that when setting an encoded plus sign '+' in query part it doesn't \
get decoded by KUrl::url(). Needed for uri intended to submit html forms where an \
unencoded '+' means a space char.

M  +11   -0    kdecore/tests/kurltest.cpp

http://commits.kde.org/kdelibs/e8b29e145745c008ecc893e3f9ce00f291884184

diff --git a/kdecore/tests/kurltest.cpp b/kdecore/tests/kurltest.cpp
index a5a537f..d628665 100644
--- a/kdecore/tests/kurltest.cpp
+++ b/kdecore/tests/kurltest.cpp
@@ -111,6 +111,13 @@ void KUrlTest::testSetQuery()
   QCOMPARE( url1.query(), QString("?") );
   url1.setQuery( QString() );
   QCOMPARE( url1.query(), QString() );
+
+  url1.setQuery("4=2+2");
+  QCOMPARE( url1.url(), QString("http://www.kde.org/foo.cgi?4=2+2"));
+  QCOMPARE( url1.query(), QString("?4=2+2"));
+  url1.setQuery("4=2%2B2");
+  QCOMPARE( url1.url(), QString("http://www.kde.org/foo.cgi?4=2%2B2")); // %2B \
should not be decoded to + +  QCOMPARE( url1.query(), QString("?4=2%2B2"));
 }
 
 void KUrlTest::testEmptyNullReference()
@@ -272,6 +279,10 @@ void KUrlTest::testSimpleMethods() // to test parsing, mostly
   QCOMPARE( url0.htmlRef(), QString("/?:@-._~!$&'()*+,;=%A") );
   QCOMPARE( url0.url(), QString("http://www.kde.org#/?:@-._~!$&'()*+,;=%25A") );
 
+  url0 = "http://www.kde.org/foo.cgi?4=2+2";
+  QCOMPARE( url0.url(), QString("http://www.kde.org/foo.cgi?4=2+2") );
+  url0 = "http://www.kde.org/foo.cgi?4=2%2B2";
+  QCOMPARE( url0.url(), QString("http://www.kde.org/foo.cgi?4=2%2B2") );  // %2B \
should not be decoded to +  
   KUrl fileURL( "file:///home/dfaure/myfile" );
   QCOMPARE( fileURL.url(), QString("file:///home/dfaure/myfile") );


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic