<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.kde.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.6"
          urlbase="https://bugs.kde.org/"
          
          maintainer="sysadmin@kde.org"
>

    <bug>
          <bug_id>140291</bug_id>
          
          <creation_ts>2007-01-19 14:34:17 +0000</creation_ts>
          <short_desc>Imap password should be properly escaped</short_desc>
          <delta_ts>2007-01-20 21:06:36 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>10</classification_id>
          <classification>Unmaintained</classification>
          <product>mailody</product>
          <component>general</component>
          <version>unspecified</version>
          <rep_platform>unspecified</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>NOR</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Tommi Tervo">tommi.tervo</reporter>
          <assigned_to name="Tom Albers">toma</assigned_to>
          
          
          <cf_commitlink></cf_commitlink>
          <cf_versionfixedin></cf_versionfixedin>
          <cf_sentryurl></cf_sentryurl>
          <votes>0</votes>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>502537</commentid>
    <comment_count>0</comment_count>
    <who name="Tommi Tervo">tommi.tervo</who>
    <bug_when>2007-01-19 14:34:17 +0000</bug_when>
    <thetext>Version:           0.3.1-svn (using KDE 3.5.5, compiled sources)
Compiler:          Target: i486-linux-gnu
OS:                Linux (i686) release 2.6.12-10-386

mailody: IMAP C   : a02 login &quot;luser&quot; &quot;pass&quot;Word&quot;
mailody: IMAP S(0): a02 BAD Protocol Error: &quot;Unexpected additional characters at the end of command&quot;.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>502544</commentid>
    <comment_count>1</comment_count>
    <who name="Tom Albers">toma</who>
    <bug_when>2007-01-19 14:57:46 +0000</bug_when>
    <thetext>SVN commit 625208 by toma:

Quote login and password. Please check if it works, there is nothing in the IMAP rfc about this. Copied KDE kioslave behaviour, so should be ok.
BUG: 140291


 M  +22 -3     imap.cpp  
 M  +1 -0      imap.h  


--- trunk/playground/pim/mailody/src/imap.cpp #625207:625208
@@ -95,7 +95,8 @@
     else
     {
         m_queue.prepend(Queue(Queue::Auth, &quot;&quot;,
-                    &quot;login \&quot;&quot; + login + &quot;\&quot; \&quot;&quot; + pass + &quot;\&quot;&quot;));
+                    &quot;login \&quot;&quot; + quoteIMAP(login) 
+                    + &quot;\&quot; \&quot;&quot; + quoteIMAP(pass) + &quot;\&quot;&quot;));
         m_currentQueueItem=Queue();
         emit statusReady();
 
@@ -125,8 +126,8 @@
     }
     if (result == KPasswordDialog::Accepted)
         m_queue.prepend(Queue(Queue::Auth, &quot;&quot;,
-                        &quot;login \&quot;&quot; + login + &quot;\&quot; \&quot;&quot; +
-                                QString(password) + &quot;\&quot;&quot;));
+                        &quot;login \&quot;&quot; + quoteIMAP(login) + &quot;\&quot; \&quot;&quot; +
+                                quoteIMAP(QString(password)) + &quot;\&quot;&quot;));
     password.fill(0); // safe enough?
     m_currentQueueItem=Queue();
     emit statusReady();
@@ -1145,6 +1146,24 @@
     m_imap-&gt;reconnect();
 }
 
+/* Copy from KDE/3.5/kdepim/kioslaves/imap4/rfcdecoder.cc */
+/* Copyright (C) 2000 s.carstens@gmx.de */
+/* replace &quot; with \&quot; and \ with \\ &quot; and \ characters */
+QString Imap::quoteIMAP(const QString &amp;src)
+{
+    uint len = src.length();
+    QString result;
+    result.reserve(2 * len);
+    for (unsigned int i = 0; i &lt; len; i++)
+    {
+        if (src[i] == &apos;&quot;&apos; || src[i] == &apos;\\&apos;)
+            result += &apos;\\&apos;;
+        result += src[i];
+    }
+    //result.squeeze(); - unnecessary and slow
+    return result;
 }
 
+}
+
 #include &quot;imap.moc&quot;
--- trunk/playground/pim/mailody/src/imap.h #625207:625208
@@ -232,6 +232,7 @@
     void integrity(const QString&amp; mb, int);
     void timerEvent( QTimerEvent * );
     void getCapabilities();
+    QString quoteIMAP(const QString &amp;src);
 
   signals:
     /**
</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>502853</commentid>
    <comment_count>2</comment_count>
    <who name="Tommi Tervo">tommi.tervo</who>
    <bug_when>2007-01-20 21:06:36 +0000</bug_when>
    <thetext>Confirmed, fix works fine</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>