Saturday, October 10, 2009

Fixing a fun little problem: FF to IE bookmark import

For a number of not so complex reasons, I decided to try rolling back to the dark-side at work and migrate back from Firefox to Internet Explorer as my primary web-browser there..

While I did use IE (version 8) periodically and kept a smattering of “Favorites” bookmarks, it wasn’t my daily browser.  That was reserved for Firefox.

In Firefox I had amassed quite a large and sophisticated collection of bookmarks in a highly organized folder structure.

So naturally I wanted to bring them over into IE.

So from the file-menu in Firefox I just did the “Bookmarks” –> “Organize Bookmarks” –> “Import and Backup” –> “Export HTML” routine.

That generated a “bookmarks.html” file.  Easy peasy.

At first I “cheated” and just opened that file in IE and make a Favorites link to it on my favorites bar.  When clicked, it opened the list as a single HTML formatted page and I would just scroll down to find the link I was looking for. This worked well enough but there were a lot of links and a lot of scrolling.

I eventually decided it was time to import them directly into IE as “real” folders/favorites.

So in IE I created a new “FF Imported” folder and then went through the “File” –> “Import and Export” –> “Import from a File” –> “Favorites” –> and selected the bookmarks.html file Firefox exported.

In the past I’ve always had a 100% success rate and didn’t expect any issues.

However this time it ran for a few seconds, then generated a failure error.  What?  Never had that issue before.

Looking in my importation folder I found that some of the bookmarks/folders had imported but only about 10% or so.  Strange.

So I went to delete the folder and start again.

Only one Favorites folder wouldn’t budge.  No matter which of multiple techniques I attempted to ply.

It was named “Holding..” and had nothing (really, nothing) inside it.  It was actually a subfolder but I couldn’t delete the parent folder either.

Eventually I decided that the double-periods might be mucking things up and somehow making it be an “invalid” folder name thus giving the system fits dealing with it.  I suppose I could have just left it but that seemed messy.

Luckily I remembered an old GSD post where I had mentioned Delete FXP Files (free-edition) -

This fantastically clever utility from JRTwine Software continues to amaze me. It isn't something most sysadmins will regularly need. See, every now and then you may come across a file or directory that somehow got named something that Windows just won't let you delete. It's not that it is "locked" per-se in the normal sense, but that the name itself makes Windows balk and your deletion request. I highly recommend this tool and suggest you keep it handy, just in case.

So I popped over there and downloaded the old version, installed it, and in seconds, had the offending folder cleanly and decisively removed. No fuss.  Delete FXP Files remains a fantastic tool that is probably almost never needed; but when you do, you really will be glad to have it handy.  Note, I also found that there is a much enhanced Delete FXP Files 2009 version out now as well.  Check it out!  Well worth the value purchase price…

Anyway, that fixed my initial headache, but didn’t bring me any closer to figuring out the importation failure.

But I did have a clue.  Somehow in the importation process, a folder had been created with an “invalid” folder name.  Did maybe other shenanigans lurk in my bookmarks.html file?

Not wanting to repeat the invalid folder name fiasco on my next attempt, I opened up the bookmarks.html file in Notepad++ and looking through the HTML code, quickly found the code entry that created the “Holding..” folder name.

Despite the mean “DO NOT EDIT!” comment at the top of the file text, I felt fairly confident changing the hyperlink text name reference so that the folder was now named “Holding” without the double-periods.

I also knew I had a number of other bookmarks in there that didn’t carry any text at all.  In Firefox they were on my bookmarks toolbar identified as “favicons” to cut down on space.  So I edited them as well to have a brief text name now.

The more I got to looking through the remaining exported Firefox bookmark code, the more bookmarks I found in HTML code that had names with potentially/really invalid file/folder name characters, or special characters, etc.  So I ended up editing them all to have more simplified (and allowed) names.  Took quite a while.

When I was finally done, I went back and attempted to import the now-modified bookmarks.html file into IE.

This time it imported perfectly with no errors!

Hurrah!

So the problem and solution was quite clear…but why might this have occurred?

I think it very simple.

Version 3.x builds of Firefox use JSON/SQLite based databases to manage the new Places bookmarking structure.  As such, it really doesn’t seem to care what you name a bookmark or what characters you use to name it.  Spaces, slashes, combos of symbols, it all seems pretty much valid.  Even no-named bookmarks (icon only) are allowed.

The “problem” lies in the IE method of “Favorites” bookmark management.  Instead of using a database format to store them, pop into the user account folder and look for the “Favorites” folder.  Yep. Same old Windows file/folder structure.  Bookmark folders are really folders, and the bookmarks are actually files with “name.url” format.  The Registry helps control how these are ordered/displayed in the IE browser, but while great to know, that is not directly related to this particular issue.  (more details of the IE Bookmarks/Registry connection here: CodeProject: Internet Explorer Favorites) from Jean-Paul Mikkers.)

Sidenote: Could this provide a possible forensics angle?   Might be good for registry analysis folks…I’m curious if the registry entries might temporarily survive if say someone attempted to delete their user profile “Favorites” folder/contents to hide bookmarks or used a IE “washer” application.  Would these Registry items survive as remnants if IE hadn’t been re-launched and the keys/values hadn’t had a chance to be rebuilt?  Would they remain for a while in a backup registry file or restore point file?

Anyway, as such, during the importation process, it reads the bookmark.html file, strips out just the required name/link bits to recreate the folders and bookmark structure.  If any of those folders/links are names something invalid, it might successfully create a folder so named (but unable to be renamed/moved/deleted by the system) or outright crash/error-out during the importation process.

There are a few third-party tools that offer to export/import bookmarks between different browsers (Transmute pops first into my mind).  I guess I could have tried one in this application, but it seemed at first blush to have been a very simple thing to do.

Now I know better and hopefully you will as well.

Like I said…a fun exercise.

(And rest assured, Firefox remains my preferred/recommended daily web-browser.  Like I said, this was just a work-thing exercise.)

Cheers!

Claus V.

No comments: