Open
Bug 183496
Opened 22 years ago
Updated 4 years ago
selection toString() method erroneously converts <cr><lf> to <space>
Categories
(Core :: DOM: Selection, defect, P5)
Tracking
()
NEW
People
(Reporter: neil, Unassigned)
Details
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.2.1) Gecko/20021130
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.2.1) Gecko/20021130
a) sorry of this is the wrong section to file this in; seemed the closest.
b) this may actually not be a bug, but some bizarre function of format=flowed
that I'm not aware of
Simply put, I am trying to get the current selection in a mail window as a JS
string (this for re-integrating links broken across lines), but I'm getting
inconsistent results.
I tried to use a modified version of comm's nsContextMenu.js:searchSelected
(below) as I didn't want it's deafult of converting <cr>s & <lf>s to <space>.
However, sometimes the toString() method gives me the "\r\n" on line breaks as
I'd expect, and sometimes it converts these to a <space> - meaning I can't
distinguish line breaks from spaces (which I need to turn to "%20").
As best as I can determine, the 'bug' occurs when an email is *not* marked as
content format=flowed. In this case, <cr><lf> is converted to <space> upon
toString() (but correctly survices cut'n'paste).
If format=flowed is present, the toString() works as ]I] expected.
I believe that toString() should not be making assuptions about format where
none is specified. I think this is the one out of nsISelection.cpp
Here's the version of the method I try to use:
function rawSearchSelected(context)
{
var focusedWindow = document.commandDispatcher.focusedWindow;
var searchStr = focusedWindow.__proto__.getSelection.call(focusedWindow);
searchStr = searchStr.toString(); /* the culprit */
searchStr = searchStr.replace( /^\s+/, "" );
searchStr = searchStr.replace(/(\n|\r)+/g, "");
searchStr = searchStr.replace(/\t/g, " ");
searchStr = searchStr.replace(/\s+$/,"");
return searchStr;
}
Reproducible: Always
Steps to Reproduce:
1. Receive email *without* format=flowed [how in Moz? I had to do it 'raw']
2. Try to extract a multi-line selction as string in JS (see quoted func. above).
E.g., content of selectiun is:
http://www.go
ogle.com/
Actual Results:
"http://www.go ogle.com/"
Expected Results:
"http://www.go\r\nogle.com\r\n"
Comment 2•22 years ago
|
||
Selection.
Assignee: dom_bugs → mjudge
Status: UNCONFIRMED → NEW
Component: DOM Level 0 → Selection
Ever confirmed: true
QA Contact: desale → pmac
Updated•15 years ago
|
Assignee: mjudge → nobody
QA Contact: pmac → selection
Comment 3•4 years ago
|
||
Bulk-downgrade of unassigned, >=5 years untouched DOM/Storage bugs' priority and severity.
If you have reason to believe this is wrong, please write a comment and ni :jstutte.
Severity: normal → S4
Priority: -- → P5
You need to log in
before you can comment on or make changes to this bug.
Description
•