Bug 276204 - KUrl::htmlRef() return empty string whenever must return null string
Summary: KUrl::htmlRef() return empty string whenever must return null string
Status: RESOLVED FIXED
Alias: None
Product: kdelibs
Classification: Unmaintained
Component: kdecore (show other bugs)
Version: unspecified
Platform: Unlisted Binaries Linux
: NOR normal
Target Milestone: ---
Assignee: kdelibs bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-06-21 18:03 UTC by Andrea Iacovitti
Modified: 2011-08-06 22:54 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andrea Iacovitti 2011-06-21 18:03:29 UTC
Version:           unspecified (using KDE 4.6.4) 
OS:                Linux

KUrl::htmlRef() return empty string whenever must return null string

Consider an url u with no fragment part: KUrl u("http://www.kde.org")

While u.ref() correctly return NULL string,  u.htmlRef() return EMPTY string.
That's not correct, u.htmlRef() must return NULL string too.

Reproducible: Always




Possible patch:

--- kdelibs/kdecore/io/kurl.cpp
+++ kdelibs/kdecore/io/kurl.cpp
@@ -1490,11 +1490,11 @@
 {
   if ( !hasSubUrl() )
   {
-      return QUrl::fromPercentEncoding( ref().toLatin1() );
+      return fragment();
   }
 
   const List lst = split( *this );
-  return QUrl::fromPercentEncoding( (*lst.begin()).ref().toLatin1() );
+  return (*lst.begin()).fragment();
 }
 
 QString KUrl::encodedHtmlRef() const
Comment 1 David Faure 2011-06-23 12:23:07 UTC
Git commit 9fbd6def08325b0b0acb97d19b8a07f99f099996 by David Faure.
Committed on 23/06/2011 at 11:55.
Pushed by dfaure into branch 'master'.

Fix null/empty confusion in KUrl::htmlRef() and its unittests.

Patch by Andrea Iacovitti <aiacovitti@libero.it>, who wrote:

This aims to be a fix for bug #276204 related to htmlRef(), and the kurl unit
test that return a false positive because of QCOMPARE treating QString("") == QString()
After fixing the unit test related to url reference stuff, 2 of them failed.
One related to htmlRef() (as in #276204),
the other related to setRef() not able to set Empty (but not Null) ref.
-> fixed setRef() too.
CCBUG: 276204

M  +4    -4    kdecore/io/kurl.cpp     
M  +29   -9    kdecore/tests/kurltest.cpp     
M  +1    -0    kdecore/tests/kurltest.h     

http://commits.kde.org/kdelibs/9fbd6def08325b0b0acb97d19b8a07f99f099996
Comment 2 David Faure 2011-06-27 10:21:54 UTC
OK, actually this fixes the bug, we can close it.
Comment 3 Andrea Iacovitti 2011-07-21 18:52:51 UTC
Git commit 52718deb48f3419bf282b2059a45ac0ab8bde363 by Andrea Iacovitti.
Committed on 21/07/2011 at 20:41.
Pushed by aiacovitti into branch 'master'.

Additional unittests for setRef() and setHTMLRef()
CCBUG: 276204

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

http://commits.kde.org/kdelibs/52718deb48f3419bf282b2059a45ac0ab8bde363
Comment 4 David Faure 2011-08-06 17:18:41 UTC
Git commit 7977f1a8d7145ddadebfc539eef8af7011bd897e by David Faure.
Committed on 23/06/2011 at 11:55.
Pushed by dfaure into branch 'KDE/4.7'.

Fix null/empty confusion in KUrl::htmlRef() and its unittests.

Patch by Andrea Iacovitti <aiacovitti@libero.it>, who wrote:

This aims to be a fix for bug #276204 related to htmlRef(), and the kurl unit
test that return a false positive because of QCOMPARE treating QString("") == QString()
After fixing the unit test related to url reference stuff, 2 of them failed.
One related to htmlRef() (as in #276204),
the other related to setRef() not able to set Empty (but not Null) ref.
-> fixed setRef() too.
CCBUG: 276204

M  +1    -0    kdecore/tests/kurltest.h
M  +4    -4    kdecore/io/kurl.cpp
M  +29   -9    kdecore/tests/kurltest.cpp

http://commits.kde.org/kdelibs/7977f1a8d7145ddadebfc539eef8af7011bd897e
Comment 5 David Faure 2011-08-06 22:54:42 UTC
Git commit f34fcae00b35716bee68df436a53630776591f91 by David Faure, on behalf of Andrea Iacovitti.
Committed on 21/07/2011 at 20:41.
Pushed by dfaure into branch 'KDE/4.7'.

Additional unittests for setRef() and setHTMLRef()
CCBUG: 276204

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

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