Bug 1692771 Comment 12 Edit History

Note: The actual edited comment in the bug view page will always show the original commenter’s name and original timestamp.

`ScanHTML()` searches the text nodes in HTML, and enriches user-written plaintext URLs with clickable links. It's specifically designed to run after (or during, if you wish) HTML email composition and turn manually typed URLs into links. It does not touch existing explicitly <a href> links, only adds those that are missing. It recognizes a number of different kinds of links. Those in comment 10 were only an excerpt. It should really be used in this case, and not some other implementation.

```
cs = Cc["@mozilla.org/txttohtmlconv;1"].getService(Ci.mozITXTToHTMLConv);
cs.scanHTML('<span>www.foobar.com</span>', Ci.mozITXTToHTMLConv.kURLs)
// "<span><a class=\"moz-txt-link-abbreviated\" href=\"http://www.foobar.com\">www.foobar.com</a></span>"
```

If you run that output HTML through our HTML->TXT converter, you will see that you get the original `www.foobar.com` back, fixing this bug.

If we're not using ScanHTML() to look for URLs during email sending, then that's the bug here. Can you please show us the relevant code? I don't know where it is in the new JS implementation.
`ScanHTML()` searches the text nodes in HTML, and enriches user-written plaintext URLs with clickable links. It's specifically designed to run after (or during, if you wish) HTML email composition and turn manually typed URLs into links. It does not touch existing explicitly <a href> links, only adds those that are missing. It recognizes a number of different kinds of links. Those in comment 10 were only an excerpt. It should really be used in this case, and not some other implementation.

```
userhtmlinput = '<span>www.foobar.com</span>';
cs = Cc["@mozilla.org/txttohtmlconv;1"].getService(Ci.mozITXTToHTMLConv);
output = cs.scanHTML(userinput, Ci.mozITXTToHTMLConv.kURLs);
// "<span><a class=\"moz-txt-link-abbreviated\" href=\"http://www.foobar.com\">www.foobar.com</a></span>"

parserUtils = Cc["@mozilla.org/parserutils;1"].getService(Ci.nsIParserUtils);
plaintext = parserUtils.convertToPlainText(output, Ci.nsIDocumentEncoder.OutputFormatted, 80);
console.log(userhtmlinput);
console.log(output);
console.log(plaintext);
```

If you run that output HTML through our HTML->TXT converter, you will see that you get the original `www.foobar.com` back, fixing this bug.

If we're not using ScanHTML() to look for URLs during email sending, then that's the bug here. Can you please show us the relevant code? I don't know where it is in the new JS implementation.
`ScanHTML()` searches the text nodes in HTML, and enriches user-written plaintext URLs with clickable links. It's specifically designed to run after (or during, if you wish) HTML email composition and turn manually typed URLs into links. It does not touch existing explicitly <a href> links, only adds those that are missing. It recognizes a number of different kinds of links. Those in comment 10 were only an excerpt.

```
userhtmlinput = '<span>www.foobar.com</span>';
cs = Cc["@mozilla.org/txttohtmlconv;1"].getService(Ci.mozITXTToHTMLConv);
output = cs.scanHTML(userinput, Ci.mozITXTToHTMLConv.kURLs);
// "<span><a class=\"moz-txt-link-abbreviated\" href=\"http://www.foobar.com\">www.foobar.com</a></span>"

parserUtils = Cc["@mozilla.org/parserutils;1"].getService(Ci.nsIParserUtils);
plaintext = parserUtils.convertToPlainText(output, Ci.nsIDocumentEncoder.OutputFormatted, 80);
console.log(userhtmlinput);
console.log(output);
console.log(plaintext);
```

If you run that output HTML through our HTML->TXT converter, you will see that you get the original `www.foobar.com` back, fixing this bug.

If we're not using ScanHTML() to look for URLs during email sending, then that's the bug here. Can you please show us the relevant code? I don't know where it is in the new JS implementation.

Back to Bug 1692771 Comment 12