Coder Social home page Coder Social logo

Comments (6)

mjs avatar mjs commented on May 30, 2024

Original comment by Menno Smits (Bitbucket: mjs0):


Fixed in r142.
Thanks

from imapclient.

mjs avatar mjs commented on May 30, 2024

Original comment by Menno Smits (Bitbucket: mjs0):


Thanks, I'll try and get this sorted before the 0.6 release goes out.

from imapclient.

mjs avatar mjs commented on May 30, 2024

Original comment by Mark Eichin (Bitbucket: eichin):


Working with trunk (r139), it looks like it again does the wrong thing with a gmail folder name that begins with quotes (as opposed to merely containing them); a folder named
"Make" Magazine (ORA)
becomes
Make" Magazine (ORA

Turning off this bit of re-unquoting from r103 fixes my case, but I don't know if it impacts non-gmail IMAP servers...

diff -r be5626eee037 imapclient/response_parser.py
--- a/imapclient/response_parser.py Wed Mar 17 02:10:37 2010 +0000
+++ b/imapclient/response_parser.py Wed Mar 17 02:13:56 2010 -0400
@@ -207,8 +207,8 @@
raise ParseError('Expecting literal of size %d, got %d' % (
literal_len, len(literal_text)))
return literal_text

  • elif token.startswith('"'):
  •    return token[1:-1]
    
  • #elif token.startswith('"'):
  • return token[1:-1]

elif token.isdigit():
return int(token)
else:

from imapclient.

mjs avatar mjs commented on May 30, 2024

Original comment by Menno Smits (Bitbucket: mjs0):


Fixed in r91 thru r95

from imapclient.

mjs avatar mjs commented on May 30, 2024

Original comment by Mark Eichin (Bitbucket: eichin):


Replying to [comment:2 mjs0]:

Possible workaround (with debugging still in)...

  1. use a named backref qqq in re_folder, so that we can use a greedy match on the foldername regardless of whether or not it has quotes (ie. if and only if there's a start quote, match an end one)
  2. use a named ref for the folder name itself
  3. clean up the extra quoting (in list_folders, though list_sub_folders needs both 2 and 3 as well)

With these changes, all of my gmail foldernames round-trip from list_folders back to select_folder, except for [Gmail] itself; I haven't tested this against any other implementation. extract_folder_from_line probably needs to be a common function called by list_folders and list_sub_folders anyway, instead of a shared regexp.

diff -r 5ac3ccadb5fc imapclient/imapclient.py
--- a/imapclient/imapclient.py  Fri Dec 18 17:17:30 2009 +0000
+++ b/imapclient/imapclient.py  Sun Dec 27 01:50:30 2009 -0500
@@ -63,7 +63,7 @@
     ReadOnlyError = imaplib.IMAP4.readonly

     re_sep = re.compile('^\(\("[^"]*" "([^"]+)"\)\)')
-    re_folder = re.compile('\([^)]*\) "[^"]+" "?([^"]+)"?')
+    re_folder = re.compile(r'\([^)]*\) "[^"]+" (?P<qqq>"?)(?P<folder>.+)(?P=qqq)')
     re_status = re.compile(r'^\s*"?(?P<folder>[^"]+)"?\s+'
                            r'\((?P<status_items>.*)\)$')

@@ -169,7 +169,10 @@
             else:
                 match = self.re_folder.match(line)
                 if match:
-                    folder_text = match.group(1)
+                    folder_text = match.group("folder")
+                    print "matched folder", repr(folder_text), "in", repr(line)
+                    folder_text = folder_text.replace('\\"', '"')
+                    print "  fixed folder", repr(folder_text)
             if folder_text is not None:
                 folders.append(self._decode_folder_name(folder_text))
         return folders

from imapclient.

mjs avatar mjs commented on May 30, 2024

Original comment by Menno Smits (Bitbucket: mjs0):


This problem doesn't occur with all IMAP servers. Gmail uses backslash escaping so the problem occurs there. Dovecot returns folders with double quotes in a literal which doesn't trip IMAPClient up.

Example Gmail response:

* LIST (\HasNoChildren) "/" "Test \"folder\""

The new response parser should handle this cleanly. It should be possible to use a temporary fix in the mean time.

from imapclient.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.