[XML-SIG] xbel_parse bug, and new xbel bug report/fix

Thomas B. Passin tpassin@idsonline.com
Wed, 15 Sep 1999 00:34:01 -0400


 > xbel_parse.py does not properly convert "&"s in URLs to the & character 
  > xbel_parse.py does not properly convert "&"s in URLs to the & character 
 > entity.  I haven't checked its handling of < or " yet.

In using the xbel package in the 0.5.1 package against Internet Explorer bookmarks, I had the same problem.  Actually, the problem I had is not exactly in converting "&" characters.  msie_parse.py correctly replaces them with "&" entities.
But xbel2html then gives errors trying to process them.

Until this is fixed, I am using a text editor on the xbel file to replace all & and & with printable character groups.  After running xbel2html I am replacing them back to the correct values.  Of course you could do this with an awk or python script easily.

There is ANOTHER BUG in the package.  msie_parse.py does not nest folders correctly at all - the nesting level keeps increasing from folder to folder.

Here is a PATCH  to fix the problem:

in msie_parse.py, add the single line shown below: 

class MSIE:
    # internet explorer

    def __init__(self,bookmarks, path):
        self.root = None
        self.path = path


    def __walk(self, subpath=[]):
        # traverse favourites folder
        path = os.path.join(self.path, string.join(subpath, os.sep))
        for file in os.listdir(path):
            fullname = os.path.join(path, file)
            if os.path.isdir(fullname):
                self.__walk(subpath + [file])
# ======= Add the following line: =======
                self.bms.leave_folder()  # go back up a level when done with the children
# ==============================
                url = self.__geturl(fullname)
                if url:

This fixes the problem, and it works fine with empty folders too.  I haven't looked to see if the equivalent programs for Netscape, etc. bookmarks have similar problems.


Tom Passin