diff options
author | Jon Leighton <j@jonathanleighton.com> | 2018-02-14 22:04:28 +0100 |
---|---|---|
committer | Jon Leighton <j@jonathanleighton.com> | 2018-02-16 11:24:12 +0100 |
commit | 32f781234a07c6aa52e8105d5aa32bec3f4791a1 (patch) | |
tree | 741291c719a41f189cbb9e7a994824d9e4aa320f /components/script/dom/textcontrol.rs | |
parent | 7e31ae35e1036467e25484ab30132f8bd49f0ee8 (diff) | |
download | servo-32f781234a07c6aa52e8105d5aa32bec3f4791a1.tar.gz servo-32f781234a07c6aa52e8105d5aa32bec3f4791a1.zip |
Disallow mutating the internals of TextInput
The TextInput::assert_ok_selection() method is meant to ensure that we
are not getting into a state where a selection refers to a location in
the control's contents which doesn't exist.
However, before this change we could have a situation where the
internals of the TextInput are changed by another part of the code,
without using its public API. This could lead to us having an invalid
selection.
I did manage to trigger such a situation (see the test added in this
commit) although it is quite contrived. There may be others that I
didn't think of, and it's also possible that future changes could
introduce new cases. (Including ones which trigger panics, if indexing
is used on the assumption that the selection indices are always valid.)
The current HTML specification doesn't explicitly say that
selectionStart/End must remain within the length of the content, but
that does seems to be the consensus reached in a discussion of this:
https://github.com/whatwg/html/issues/2424
The test case I've added here is currently undefined in the spec which
is why I've added it in tests/wpt/mozilla.
Diffstat (limited to 'components/script/dom/textcontrol.rs')
-rw-r--r-- | components/script/dom/textcontrol.rs | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/components/script/dom/textcontrol.rs b/components/script/dom/textcontrol.rs index b47167ae937..fa6c8d0b604 100644 --- a/components/script/dom/textcontrol.rs +++ b/components/script/dom/textcontrol.rs @@ -257,7 +257,7 @@ impl<'a, E: TextControlElement> TextControlSelection<'a, E> { } fn direction(&self) -> SelectionDirection { - self.textinput.borrow().selection_direction + self.textinput.borrow().selection_direction() } // https://html.spec.whatwg.org/multipage/#set-the-selection-range |