gerw / vim-latex-suite

71 stars 16 forks source link

url problems in bibtools.py on windows #28

Closed tianxiaogu closed 8 years ago

tianxiaogu commented 8 years ago

I found there is a problem when using urlopen to open a bib file on windows with python 2.7.9.

What about using pathname2url instead of quote at line 199 in bibtools.py?

More details can be found here

The following patch works for me, python 2.7.9 on windows 10.

diff --git a/ftplugin/latex-suite/bibtools.py b/ftplugin/latex-suite/bibtools.py
index d013d7d..19b7ee2 100644
--- a/ftplugin/latex-suite/bibtools.py
+++ b/ftplugin/latex-suite/bibtools.py
@@ -6,10 +6,10 @@ import re
 import os

 try:
-    from urllib.request import urlopen
+    from urllib.request import urlopen, pathname2url
     from urllib.parse import quote
 except ImportError:
-    from urllib import urlopen
+    from urllib import urlopen, pathname2url
     from urllib import quote

 # Compatibility functions
@@ -196,7 +196,7 @@ class BibFile:
                 self.addfile(f)

     def addfile(self, file):
-        fields = urlopen('file://' + quote(os.path.abspath(file))).read().decode('utf-8').split('@')
+        fields = urlopen('file:' + pathname2url(os.path.abspath(file))).read().decode('utf-8').split('@')
         for f in fields:
             if not (f and re.match('string', f, re.I)):
                 continue
gerw commented 8 years ago

Thank you! Should be fixed now.