Last Comment Bug 866638 - History import from Safari on OS X does not work
: History import from Safari on OS X does not work
[good first bug][mentor=gavin]
Product: Firefox
Classification: Client Software
Component: Migration (show other bugs)
: 20 Branch
: x86 Mac OS X
-- normal (vote)
: Firefox 25
Assigned To: Steven MacLeod [:smacleod]
: Matthew N. [:MattN] (PM if requests are blocking you)
Depends on:
  Show dependency treegraph
Reported: 2013-04-29 03:25 PDT by maniac_warlord
Modified: 2013-06-26 11:42 PDT (History)
7 users (show) in‑testsuite-
See Also:
Crash Signature:
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---

Patch (1.92 KB, patch)
2013-06-25 14:58 PDT, Steven MacLeod [:smacleod] review+
Details | Diff | Splinter Review

Description User image maniac_warlord 2013-04-29 03:25:46 PDT
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:20.0) Gecko/20100101 Firefox/20.0
Build ID: 20130326150557

Steps to reproduce:

I tried to import Safari history on OS X via Bookmark Manager » Import Data From Another Browser… » Safari » (any combination including history).

Actual results:

Success message displayed for all previously selected data types.
Bookmarks (if selected) are properly imported, but not a single history entry is imported.

Expected results:

Browsing history should have been imported.

Additional information:
- Issue occurs on 20.0 and 21.0 (current beta) in both used and new user profiles.
- The history file I'm trying to import contains ~80,000 entries and is 17MB.
- OS X 10.8.2 with Safari 6.0.2
Comment 1 User image Tiziana Sellitto [:tiziana] 2013-04-30 09:07:06 PDT
History has been correctly imported for me on Mac OS 10.8.3 with Safari 6.0.4 but with a history file smaller than yours and dates since a month ago;

Have you tried with a different Mac User Profile (since should not be a Profile Manager as in Firefox) and a Safari with a smaller and more recent history? I'd like to investigate if it is something ralated to the size or the dates.

Comment 2 User image maniac_warlord 2013-04-30 10:15:58 PDT
Upgraded to OS X 10.8.3 and Safari 6.0.3 since the original report.

Safari was set to delete history after 1 year. Setting it to 1 month and restarting Safari to delete older entries (file shrunk to 1.3M binary plist), then importing again into a new profile in FF 21.0 beta didn't work either: Success message, but nothing imported.

I read omni.ja!/components/SafariProfileMigrator.js and tried to get the error message about the invalid format ('Unexpected history-property list format') by replacing History.plist by a copy of the differently formatted Bookmarks.plist -- no error then either!

Deleting ~/Library/Safari/History.plist results in the option to import history disappearing (so I'm probably not dealing with the wrong file).

Converting History.plist from binary to XML using `plutil -convert xml1 ~/Library/Safari/History.plist` didn't help either.

No diagnostic messages by Firefox in during import.

I'd be happy to help by e.g. patching the code in Firefox 20 omni.ja to add diagnostics if you could provide the commands.
Comment 3 User image Tiziana Sellitto [:tiziana] 2013-04-30 11:13:07 PDT
My result is the same. I've tried it again, in SAFE MODE too, but it WORKSFORME on 

Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:21.0) Gecko/20100101 Firefox/21.0
buildID : 20130425162858

Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:20.0) Gecko/20100101 Firefox/20.0
buildID: 20130326150557
Comment 4 User image Tiziana Sellitto [:tiziana] 2013-04-30 11:26:15 PDT
Try this with another Mac Account ( a new one)
Comment 5 User image maniac_warlord 2013-04-30 12:15:37 PDT
I converted my history file to XML and removed entries trying to determine which of them was responsible. I found an entry that caused the import failure (unfortunately, there seem to be others).

Here's the History.plist in XML format with a single entry failing import:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "">
<plist version="1.0">
			<string>Failed to open page</string>

Steps to reproduce:
1. In Safari, open the PDF
2. Click the link on the top.
3. Try to import your Safari browsing history into Firefox
Comment 6 User image maniac_warlord 2013-04-30 12:38:07 PDT
I've found a few other import-breaking history entries. Safari seems to store anything entered into the address bar (that isn't considered a search expression) into the history, whether it's actually a URL or not. Example:

:// (without the http)

Error page, but stored in the history, and fails to import to Firefox.

The reasonable but erroneous assumption seems to be that whatever string is specified for the empty key in Safari's history is a valid URL.
Comment 7 User image Tiziana Sellitto [:tiziana] 2013-05-01 02:13:59 PDT
(In reply to maniac_warlord from comment #6)

> :// (without the http)
> Error page, but stored in the history, and fails to import to Firefox.

This is the only case I can reproduce the bug.

Steps to reproduce:
1. Open Safari and visit a page like  :// (without the http) or any page that produce an "error page invalid address"
2. the error page is stored in the Safari history
3. Import History throught Firefox Bookmarks Manager -> Import Data from Another Browser
4. The history is not imported event id the message says "items successfully imported"

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:21.0) Gecko/20100101 Firefox/21.0
Build ID: 20130425162858

and on latest Nightly 23.0a1 (2013-04-30)
Comment 8 User image Marco Bonardo [::mak] 2013-05-02 05:33:19 PDT
looks like the code is throwing when a uri is invalid

it should try/catch on uri creation
Comment 9 User image :Gavin Sharp [email:] 2013-05-25 17:08:51 PDT
Awesome job tracking this down, maniac_warlord and Tiziana!

Should be easy to fix, per Marco's comment 8. Feel free to reach out if you are interested in writing a patch :)
Comment 10 User image Steven MacLeod [:smacleod] 2013-06-25 14:58:49 PDT
Created attachment 767447 [details] [diff] [review]
Comment 11 User image :Gavin Sharp [email:] 2013-06-25 15:15:18 PDT
Comment 12 User image Ryan VanderMeulen [:RyanVM] 2013-06-26 11:42:07 PDT

Note You need to log in before you can comment on or make changes to this bug.