<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">--- kdecore/kurl.cpp
+++ kdecore/kurl.cpp
@@ -30,6 +30,7 @@
 #include &lt;kglobal.h&gt;
 #include &lt;kidna.h&gt;
 #include &lt;kprotocolinfo.h&gt;
+#include &lt;kstringhandler.h&gt;
 #endif
 
 #include &lt;stdio.h&gt;
@@ -183,7 +184,7 @@ static QString lazy_encode( const QStrin
         (character == '?') || // Start of query delimiter
         ((character == '@') &amp;&amp; encodeAt) || // Username delimiter
         (character == '#') || // Start of reference delimiter
-        ((character == 32) &amp;&amp; (i+1 == old_length))) // A trailing space
+        ((character == 32) &amp;&amp; (i+1 == old_length || segment[i+1] == ' '))) // A trailing space
     {
       new_segment[ new_length++ ] = '%';
 
@@ -1540,7 +1541,13 @@ QString KURL::prettyURL( int _trailing )
     u += "//";
     if ( hasUser() )
     {
-      u += lazy_encode(m_strUser);
+      QString s = m_strUser;
+#ifndef KDE_QT_ONLY
+      // shorten the username, its unlikely to be valid without password anyway
+      if (!hasPass())
+          s = KStringHandler::csqueeze(s, 16);
+#endif
+      u += encode(s, 0, 0);
       // Don't show password!
       u += "@";
     }
</pre></body></html>