Closed Bug 618995 Opened 14 years ago Closed 13 years ago

Dragging a link with a line break to the bookmark bar produces two-line bookmark

Categories

(Camino Graveyard :: Bookmarks, defect)

x86
macOS
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: lthompson.22, Assigned: alqahira)

Details

Attachments

(2 files, 1 obsolete file)

User-Agent:       Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en; rv:1.9.2.14pre) Gecko/20101209 Camino/2.1a1pre (like Firefox/3.6.14pre)
Build Identifier: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en; rv:1.9.2.14pre) Gecko/20101209 Camino/2.1a1pre (like Firefox/3.6.14pre)

STR: If you have an account, go to Google Reader and drag any headline to your bookmark bar.

AR: The resulting bookmark looks mis-aligned because the bookmark title has a trailing line break in it. 

ER: The trailing break could be removed, so the bookmark appears in the bar the same as if you had right-clicked on the link, chosen "Bookmark This Link...", and bookmarked it to the bar.

The Google Reader source is too complex for me, so I don't know for sure what the cause is there. But I see the same thing with any link that has a line-break in it. In case you don't have Google reader, I put such a link on my test page at http://homepage.mac.com/lthompson.22/test.html. There's also a screenshot that you can reproduce by dragging the multi-line link to your bookmark bar.

Allowing two-line bookmarks doesn't really bother me, it's easy for users to fix. But the odd case of bookmarks for Google Reader headlines, where there's no text on the second line, prompts me to report this for your consideration.


Reproducible: Always
I meant to include in the report that neither Safari nor Chrome exhibit the issue with Google Reader headlines, and both remove line breaks from links dragged to the bookmark bar. (Firefox does not allow dragging links to the bookmark bar?)

> But the odd case of bookmarks for Google Reader headlines, 
> where there's no text on the second line

...and no indication that one should expect a two-line bookmark (as there is in my home-cooked example). When I first saw it, I thought I had found some UI-drawing glitch; it didn't immediately occur to me that it was due to a line break.
(In reply to comment #1)
> I meant to include in the report that neither Safari nor Chrome exhibit the
> issue with Google Reader headlines, and both remove line breaks from links
> dragged to the bookmark bar.

We probably need to hook up more sanitizing; specifically, we need to call |cleanedStringWithPasteboardString| on all the title flavors (and not just URLs) in NSPasteboard+Utils's |getURLs:andTitles|.

> (Firefox does not allow dragging links to the bookmark bar?)

Would not surprise me at all. :P
Status: UNCONFIRMED → NEW
Ever confirmed: true
This is Lisa's testcase, expanded to include leading and trailing linebreaks.

I guess we need to strip leading and trailing breaks, and convert internal breaks to spaces?
(In reply to comment #2)
> > (Firefox does not allow dragging links to the bookmark bar?)
> 
> Would not surprise me at all. :P

No, it seems to just reject drags whose titles have returns in them; I was able to drag other links OK.  Also, it appears to sanitize when using the "Bookmark This Link" context menu item.

At any rate, it doesn't surprise Firefox and Safari behave differently, since we share 0 code with them in this area.  It surprises me a little bit the Chrome doesn't, since they share our Pasteboard code (but it's entirely possible they've sanitized at a different place).
Attached patch Partial fix (obsolete) — Splinter Review
This sort-of fixes the problem by using |cleanedStringWithPasteboardString|.  The only issue is that it simply strips and doesn't convert internal returns into spaces, if we want to do that (I'm not sure where our fancy location-bar return-sanitizing code is).

We'd need a sister method to |cleanedStringWithPasteboardString| that instead calls |stringByReplacingCharactersInSet:withString:| and then |stringByTrimmingWhitespace|.  |cleanedTitleStringWithPasteboardString| anyone?  Or is there a method that already does that I can't find?
Assignee: nobody → alqahira
Status: NEW → ASSIGNED
(For reference, the fancy location-bar sanitizing code is apparently BWC's |cleanPastedText:| http://mxr.mozilla.org/camino/source/camino/src/browser/BrowserWindowController.mm#296  That code, while not directly useful here, raises another question, however: why aren't our control character-cleaning methods in NSString+Utils also cleaning illegals?  Why is |cleanPastedText:| the only place that does that?)

It's too late for my brain to think usefully about the issues in the last few comments; hopefully cl will have some thoughts for me tomorrow ;)
How is this different, exactly, from bug 313079, other than that one having a semi-obscure title? :-p
(In reply to comment #7)
> How is this different, exactly, from bug 313079, other than that one having a
> semi-obscure title? :-p

Well, that one seemed focused on editing bookmarks, whereas this one is drags, and then there's the obscure title, and then the fact that I'd forgotten all about that one :P

(Note also that the dragging case mentioned briefly in bug 313079 no longer reproduces, since it was a raw URL, which have since been sanitized.)
The Bookmark This Link… CM (and the AddBookmarkDialogController in general) solve this problem via http://mxr.mozilla.org/camino/source/camino/src/bookmarks/AddBookmarkDialogController.mm#57

That's probably the correct solution here, too (although maybe not for links with the URL-as-link-text; I'd have to check)--but it also raises the question of bug 619166 once again.
Attached patch FixSplinter Review
Nothing like saying what the fix is over and over again but not implementing it.

Here's |cleanedTitleStringWithPasteboardString:|, which does the same thing as AddBookmarkDialogController's |BookmarkTitleForItem| cleaning part and as HTMLBookmarkConverter's |cleanedStringFromHTMLBookmarkImport|.

Should we rename the existing |cleanedStringWithPasteboardString:| to |cleanedURLStringWithPasteboardString:| for parity and clarity?
Attachment #497442 - Attachment is obsolete: true
Attachment #512010 - Flags: review?(cl-bugs-new2)
Comment on attachment 512010 [details] [diff] [review]
Fix

r+; looks fine to me o_O
Attachment #512010 - Flags: review?(cl-bugs-new2) → review+
Comment on attachment 512010 [details] [diff] [review]
Fix

(In reply to comment #10)
> Should we rename the existing |cleanedStringWithPasteboardString:| to
> |cleanedURLStringWithPasteboardString:| for parity and clarity?

cl thought we should; Wevah said he could go either way, since that could be used on non-URLs (though it's currently not)
Attachment #512010 - Flags: superreview?(stuart.morgan+bugzilla)
Comment on attachment 512010 [details] [diff] [review]
Fix

sr=smorgan

Yes, let's do the rename.

I'm wondering if we should make the new method cleanedTitleStringFromPasteboardType:, and have it do both the fetching and cleaning, since that's what every call site does, but whichever way you prefer is fine.
Attachment #512010 - Flags: superreview?(stuart.morgan+bugzilla) → superreview+
http://hg.mozilla.org/camino/rev/4418fe40feeb with the renaming and refactoring of the two methods.
Status: ASSIGNED → RESOLVED
Closed: 13 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: