This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 13807 - Allow user-typed URLs and e-mail addresses to automatically become links
Summary: Allow user-typed URLs and e-mail addresses to automatically become links
Status: RESOLVED FIXED
Alias: None
Product: WebAppsWG
Classification: Unclassified
Component: HISTORICAL - HTML Editing APIs (show other bugs)
Version: unspecified
Hardware: All All
: P2 enhancement
Target Milestone: ---
Assignee: Aryeh Gregor
QA Contact: HTML Editing APIs spec bugbot
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 14745
  Show dependency treegraph
 
Reported: 2011-08-17 15:15 UTC by Aryeh Gregor
Modified: 2011-11-09 20:12 UTC (History)
3 users (show)

See Also:


Attachments

Description Aryeh Gregor 2011-08-17 15:15:17 UTC
Suggested by Alfonso Martínez de Lizarrondo: http://lists.whatwg.org/htdig.cgi/whatwg-whatwg.org/2011-August/032941.html


Users expect autolinking; it should probably happen by default, but with a way to disable it.  Reportedly IE supports it, and also since IE9 supports a way to disable it.  Needs research to figure out what the exact algorithm is to decide when to add a link, and what to link:

* What schemes do we recognize?
* What characters do we treat as terminating the URL?
* What if the user edits some existing text so it now looks like a URL?
* What if the user pastes a large chunk of text that contains some URLs?
* If we autolink something and the user backspaces to kill the link, how do we remember not to relink it when the user types more?

This might be why IE is the only browser to support unlinking when the user backspaces: it's the only one to autolink.  Otherwise autolinking would be pretty annoying.
Comment 1 Anne 2011-08-17 15:22:58 UTC
When I played with this they also supported auto-linking email addresses.
Comment 2 Aryeh Gregor 2011-08-17 15:38:38 UTC
Good catch, thanks.
Comment 3 Aryeh Gregor 2011-11-08 20:19:31 UTC
(In reply to comment #0)
> * What schemes do we recognize?

IE9 recognizes at least the following: http:// https:// mailto: ftp:// gopher:// file:// news: telnet://

LibreOffice 3.4.4 recognizes at least the following: http:// https:// mailto: ftp:// file:// news: telnet://a

Neither recognizes arbitrary protocols.  I would be entirely unsurprised if the set of supported protocols for IE is governed by a system-wide registry setting or something.  I think it's simplest to just recognize any protocol that looks like a hierarchical scheme, because otherwise we'd have to make political decisions about what to whitelist.  For non-hierarchical schemes, I think we can get away with minimal whitelisting, since there aren't many.  mailto: should really be enough, but let's add news: too because IE supports it (as does LibreOffice).  data: and javascript: probably aren't useful to autolink, because they generally include weird characters.

IE also recognizes things that start with \\ as URLs, which it links to file://\\....  It does not recognize things starting with "C:\" as links.  LibreOffice doesn't recognize \\.  I think I'll add the \\ behavior because Windows users might expect it, and it's not like it's used much for anything else.

> * What characters do we treat as terminating the URL?

IE seems to create the link if you hit space or Enter or such, or if the cursor moves.  LibreOffice only does it if you hit space or Enter or such.  LibreOffice's behavior seems less annoying, and simpler.

When creating the link, both IE and LibreOffice will not include some types of trailing punctuation in the link, including:

()[].,#

IE includes ' in the URL, obviously as well as / and %.  A " at the end will stop it from autolinking at all.  LibreOffice excludes ' from the URL, and a % at the end will stop it from autolinking, but a " will autolink but not be included.

> * What if the user edits some existing text so it now looks like a URL?

IE seems to turn it into a link as soon as the cursor moves.  LibreOffice won't do anything unless you go to the end and hit space or Enter or such.

> * What if the user pastes a large chunk of text that contains some URLs?

IE links them.  LibreOffice does not.  IE's behavior seems more reasonable.

> * If we autolink something and the user backspaces to kill the link, how do we
> remember not to relink it when the user types more?

IE just doesn't.  If you go back and edit it, it relinks it.  LibreOffice does too, but it's much less annoying because you have to go to the end and hit space to relink it.

LibreOffice creates a separate undo entry when you hit space, so Ctrl-Z will remove the link but not the space you just typed.  This is really nice, and I definitely plan to copy that behavior.


I think I have enough research done now to start on a spec.  Too bad I can't automatically test anything, because only WebKit supports insertText and it doesn't support autolinking (no non-IE browser does).  So it will be tedious going to figure out if my implementation makes sense.
Comment 4 Aryeh Gregor 2011-11-09 20:12:25 UTC
http://dvcs.w3.org/hg/editing/rev/9008a98bdbc9

Bug 14745 filed as followup.