Changeset 88110 in webkit
- Timestamp:
- Jun 4, 2011, 4:23:09 AM (14 years ago)
- Location:
- trunk
- Files:
-
- 1 deleted
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r88104 r88110 1 2011-06-04 Alexey Proskuryakov <ap@apple.com> 2 3 Reviewed by Darin Adler. 4 5 Input value sanitization for text fields is incorrect 6 https://bugs.webkit.org/show_bug.cgi?id=62061 7 <rdar://problem/9553273> 8 9 * fast/forms/input-value-sanitization-expected.txt: 10 * fast/forms/input-value-sanitization.html: 11 * fast/forms/paste-multiline-text-input.html: 12 * fast/forms/script-tests/input-value-sanitization.js: Removed. 13 1 14 2011-06-04 Jeffrey Pfau <jpfau@apple.com> 2 15 -
trunk/LayoutTests/fast/forms/input-value-sanitization-expected.txt
r82801 r88110 1 1 Tests for value sanitization algorithm. 2 3 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".4 5 2 6 3 … … 14 11 15 12 Text: 16 PASS input.value is " foo bar"17 PASS document.getSelection().toString() is " foo bar"13 PASS input.value is " foo bar " 14 PASS document.getSelection().toString() is " foo bar " 18 15 PASS successfullyParsed is true 19 16 -
trunk/LayoutTests/fast/forms/input-value-sanitization.html
r63876 r88110 6 6 </head> 7 7 <body> 8 <p id="description"></p>8 <p>Tests for value sanitization algorithm.</p> 9 9 <div id="console"></div> 10 <script src="script-tests/input-value-sanitization.js"></script> 10 <script> 11 var input; 12 13 debug(''); 14 debug('Number:'); 15 input = document.createElement('input'); 16 input.setAttribute('value', '65536'); 17 input.type = 'number'; 18 shouldBe('input.value', '"65536"'); 19 shouldBe('input.value = "256"; input.value', '"256"'); 20 shouldBe('input.value = ""; input.value', '""'); 21 22 23 debug(''); 24 debug('Range:'); 25 input = document.createElement('input'); 26 input.type = 'text'; 27 input.value = ':)'; 28 input.type = 'range'; 29 shouldBe('input.value', '"50"'); 30 31 debug(''); 32 debug('Text:'); 33 var container = document.createElement('div'); 34 document.body.appendChild(container); 35 container.innerHTML = '<input type="text" id="text" value="\n\r foo bar \n\r\n">'; 36 input = document.getElementById('text'); 37 shouldBe('input.value', '" foo bar "'); 38 input.focus(); 39 document.execCommand('SelectAll'); 40 shouldBe('document.getSelection().toString()', '" foo bar "'); 41 42 // FIXME: Add more sanitization tests. 43 // https://bugs.webkit.org/show_bug.cgi?id=37024 44 45 container.innerHTML = ''; 46 var successfullyParsed = true; 47 48 </script> 11 49 <script src="../../fast/js/resources/js-test-post.js"></script> 12 50 </body> -
trunk/LayoutTests/fast/forms/paste-multiline-text-input.html
r37539 r88110 11 11 12 12 var DEFAULT_LINE_1 = "line\t(1 of 2)\r\nline\t(2 of 2)"; 13 var EXPECTED_LINE_1 = "line\t(1 of 2) 13 var EXPECTED_LINE_1 = "line\t(1 of 2)line\t(2 of 2)"; 14 14 15 // FIXME: Is this really expected behavior to truncate the string at a null byte? 16 // It doesn't match Firefox 4 and common sense. 15 17 var DEFAULT_LINE_2 = "null\0char"; 16 18 var EXPECTED_LINE_2 = "null"; -
trunk/Source/WebCore/ChangeLog
r88104 r88110 1 2011-06-04 Alexey Proskuryakov <ap@apple.com> 2 3 Reviewed by Darin Adler. 4 5 Input value sanitization for text fields is incorrect 6 https://bugs.webkit.org/show_bug.cgi?id=62061 7 <rdar://problem/9553273> 8 9 Newline characters should be removed according to HTML5, not replaced with spaces. 10 This also matches Safari 5 behavior. 11 12 * html/TextFieldInputType.cpp: 13 (WebCore::isASCIILineBreak): A functor for removeCharacters(). 14 (WebCore::limitLength): Do one thing at once. 15 (WebCore::TextFieldInputType::sanitizeValue): Sanitization removes newlines. 16 (WebCore::TextFieldInputType::handleBeforeTextInsertedEvent): Moved (somewhat surprising) 17 code that replaces newlines with spaces here. 18 1 19 2011-06-04 Jeffrey Pfau <jpfau@apple.com> 2 20 -
trunk/Source/WebCore/html/TextFieldInputType.cpp
r87980 r88110 209 209 } 210 210 211 static String replaceEOLAndLimitLength(const String& proposedValue, int maxLength)212 { 213 String string = proposedValue;214 string.replace("\r\n", " "); 215 string.replace('\r', ' '); 216 string.replace('\n', ' '); 217 211 static bool isASCIILineBreak(UChar c) 212 { 213 return c == '\r' || c == '\n'; 214 } 215 216 static String limitLength(const String& string, int maxLength) 217 { 218 218 unsigned newLength = numCharactersInGraphemeClusters(string, maxLength); 219 219 for (unsigned i = 0; i < newLength; ++i) { … … 236 236 } 237 237 #endif 238 return replaceEOLAndLimitLength(proposedValue, HTMLInputElement::maximumLength);238 return limitLength(proposedValue.removeCharacters(isASCIILineBreak), HTMLInputElement::maximumLength); 239 239 } 240 240 … … 274 274 } 275 275 #endif 276 event->setText(replaceEOLAndLimitLength(event->text(), appendableLength)); 276 277 String eventText = event->text(); 278 eventText.replace("\r\n", " "); 279 eventText.replace('\r', ' '); 280 eventText.replace('\n', ' '); 281 282 event->setText(limitLength(eventText, appendableLength)); 277 283 } 278 284
Note:
See TracChangeset
for help on using the changeset viewer.