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

List:       kde-core-devel
Subject:    Re: [PATCHES] Improvements to the International Domain URLs
From:       Thiago Macieira <thiagom () wanadoo ! fr>
Date:       2003-05-28 12:13:03
[Download RAW message or body]

[Attachment #2 (multipart/mixed)]


Waldo Bastian wrote:
>When constructing error urls the encoding of the query part should be
>hard-coded to UTF-8 then, and when extracting the query it should inform
> KURL that the query is utf-8 encoded. For that KURL::queryItem(s) should
> take an encoding hint.

Thanks for the hint. That solved the problem. Now Konqueror correctly displays 
all error messages properly accentuated and with correct domain names.

I'm sending the new diffs for those modifications. I'm not including the diffs 
against kio_http and kio_smb that I sent yesterday.

Once these changes applied and tested, I believe our IDN support will be 
complete.
-- 
  Thiago Macieira  -  Registered Linux user #65028
   thiagom@mail.com           
    ICQ UIN: 1967141   PGP/GPG: 0x6EF45358; fingerprint:
    E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358

["khtml-error.diff" (text/x-diff)]

Index: khtml_part.cpp
===================================================================
RCS file: /home/kde/kdelibs/khtml/khtml_part.cpp,v
retrieving revision 1.848
diff -u -3 -p -r1.848 khtml_part.cpp
--- khtml_part.cpp	20 May 2003 12:23:54 -0000	1.848
+++ khtml_part.cpp	28 May 2003 12:06:54 -0000
@@ -101,6 +101,8 @@ using namespace DOM;
 #include "rendering/render_form.h"
 #include <kwin.h>
 
+#define HINT_UTF8	106
+
 namespace khtml {
     class PartStyleSheetLoader : public CachedObjectClient
     {
@@ -489,7 +491,7 @@ bool KHTMLPart::openURL( const KURL &url
       int error = mainURL.queryItem( "error" ).toInt();
       // error=0 isn't a valid error code, so 0 means it's missing from the URL
       if ( error == 0 ) error = KIO::ERR_UNKNOWN;
-      QString errorText = mainURL.queryItem( "errText" );
+      QString errorText = mainURL.queryItem( "errText", HINT_UTF8 );
       urls.pop_front();
       d->m_workingURL = KURL::join( urls );
       //kdDebug(6050) << "Emitting fixed URL " << d->m_workingURL.prettyURL() << endl;

["konqueror-handleerror.diff" (text/x-diff)]

? history/Makefile.in
Index: konq_run.cc
===================================================================
RCS file: /home/kde/kdebase/konqueror/konq_run.cc,v
retrieving revision 1.84
diff -u -3 -p -r1.84 konq_run.cc
--- konq_run.cc	10 May 2003 16:28:33 -0000	1.84
+++ konq_run.cc	28 May 2003 12:05:22 -0000
@@ -29,6 +29,8 @@
 
 #include <assert.h>
 
+#define HINT_UTF8	106
+
 KonqRun::KonqRun( KonqMainWindow* mainWindow, KonqView *_childView,
                   const KURL & _url, const KonqOpenURLRequest & req, bool trustedSource )
     : KParts::BrowserRun( _url, req.args, _childView ? _childView->part() : 0L, mainWindow,
@@ -141,8 +143,8 @@ void KonqRun::handleError( KIO::Job *job
    * error = int kio error code, errText = QString error text from kio
    * The sub-url is the URL that we were trying to open.
    */
-  KURL newURL = QString("error:/?error=%1&errText=%2")
-                .arg( job->error() ).arg( job->errorText() );
+  KURL newURL(QString("error:/?error=%1&errText=%2")
+	      .arg( job->error() ).arg( job->errorText()), HINT_UTF8 );
 
   m_strURL.setPass( QString::null ); // don't put the password in the error URL
 

["kurl.diff" (text/x-diff)]

Index: kdecore/kurl.h
===================================================================
RCS file: /home/kde/kdelibs/kdecore/kurl.h,v
retrieving revision 1.108
diff -u -3 -p -r1.108 kurl.h
--- kdecore/kurl.h	8 Apr 2003 19:57:14 -0000	1.108
+++ kdecore/kurl.h	28 May 2003 12:05:57 -0000
@@ -219,13 +219,6 @@ public:
   QString host() const { return m_strHost; }
 
   /**
-   * Returns the decoded hostname included in the URL in Unicode
-   * representation for use in UI elements.
-   * @return the name of the host or QString::null if no host is set
-   **/
-  QString prettyHost() const;
-
-  /**
    * Sets the hostname included in the URL.
    *
    * Special characters in the hostname will appear encoded in the URL.
@@ -482,6 +475,19 @@ public:
    * specified item does not exist.
    */
   QString queryItem( const QString& _item ) const;
+
+  /**
+   * Returns the value of a certain query item.
+   *
+   * @param _item Item whose value we want
+   * @param encoding_hint MIB of desired encoding of URL.
+   *             @see QTextCodec::mibEnum()
+   *
+   * @return the value of the given query item name or QString::null if the
+   * specified item does not exist.
+   */
+  // BIC KDE4: merge with above
+  QString queryItem( const QString& _item, int encoding_hint ) const;
 
   /**
    * Options for @ref #queryItems. Currently, only one option is
Index: kdecore/kurl.cpp
===================================================================
RCS file: /home/kde/kdelibs/kdecore/kurl.cpp,v
retrieving revision 1.240
diff -u -3 -p -r1.240 kurl.cpp
--- kdecore/kurl.cpp	30 Apr 2003 09:36:21 -0000	1.240
+++ kdecore/kurl.cpp	28 May 2003 12:05:58 -0000
@@ -105,6 +105,20 @@ static QString encode( const QString& se
   return result;
 }
 
+static QString encodeHost( const QString& segment, bool encode_slash, int encoding_hint )
+{
+  // Hostnames are encoded differently
+  // we use the IDNA transformation instead
+
+  // Note: when merging qt-addon, use QResolver::domainToAscii here
+#ifndef KDE_QT_ONLY
+  encode_slash = encoding_hint = 0; // to keep the compiler happy
+  return KIDNA::toAscii(segment);
+#else
+  return encode(segment, encode_slash, encoding_hint);
+#endif
+}
+
 static int hex2int( unsigned int _char )
 {
   if ( _char >= 'A' && _char <='F')
@@ -1211,7 +1225,7 @@ QString KURL::url( int _trailing, int en
     if (IPv6)
        u += '[' + m_strHost + ']';
     else
-       u += encode(m_strHost, true, encoding_hint);
+       u += encodeHost(m_strHost, true, encoding_hint);
     if ( m_iPort != 0 ) {
       QString buffer;
       buffer.sprintf( ":%u", m_iPort );
@@ -1260,11 +1274,7 @@ QString KURL::prettyURL( int _trailing )
     }
     else
     {
-#ifndef KDE_QT_ONLY
-       u += lazy_encode(KIDNA::toUnicode(m_strHost));
-#else
        u += lazy_encode(m_strHost);
-#endif
     }
     if ( m_iPort != 0 ) {
       QString buffer;
@@ -1643,9 +1653,9 @@ void
 KURL::setHost( const QString& _txt )
 {
 #ifndef KDE_QT_ONLY
-   m_strHost = KIDNA::toAscii(_txt).lower();
+   m_strHost = KIDNA::toUnicode(_txt);
    if (m_strHost.isEmpty())
-      m_strHost = _txt.lower(); // No idn support?
+      m_strHost = _txt.lower(); // Probably an invalid hostname, but...
 #else
    m_strHost = _txt.lower();
 #endif
@@ -1830,6 +1840,11 @@ QMap< QString, QString > KURL::queryItem
 
 QString KURL::queryItem( const QString& _item ) const
 {
+  return queryItem(_item, 0);
+}
+
+QString KURL::queryItem( const QString& _item, int encoding_hint ) const
+{
   QString item = _item + '=';
   if ( m_strQuery_encoded.length() <= 1 )
     return QString::null;
@@ -1844,7 +1859,7 @@ QString KURL::queryItem( const QString& 
       {
         QString str = (*it).mid( _len );
         str.replace( '+', ' ' ); // + in queries means space.
-        return decode_string( str );
+        return decode_string( str, encoding_hint );
       }
       else // empty value
         return QString::fromLatin1("");
@@ -1886,16 +1901,6 @@ void KURL::addQueryItem( const QString& 
      m_strQuery_encoded += '&';
   m_strQuery_encoded += item + value;
 }
-
-QString KURL::prettyHost() const 
-{ 
-#ifndef KDE_QT_ONLY
-   return KIDNA::toUnicode(m_strHost);
-#else
-   return m_strHost;
-#endif
-}
-
 
 // static
 KURL KURL::fromPathOrURL( const QString& text )

[Attachment #8 (application/pgp-signature)]

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

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