提交 44c32128 编写于 作者: B Brian Clozel

Add newline at the beginning of textarea JSP tags

This commit adds a newline char at the beginning of textarea tags
values. As per the HTML 4.01 spec (and browsers behavior), a line break
following a start tag is ignored.

This can lead to Spring's textarea tag to ignore a line break char at
the beginning of a tag value.

See https://www.w3.org/TR/html401/appendix/notes.html#notes-line-breaks

Issue: SPR-13503
上级 36e2dd90
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......@@ -98,7 +98,7 @@ public class TextareaTag extends AbstractHtmlInputElementTag {
writeOptionalAttribute(tagWriter, COLS_ATTRIBUTE, getCols());
writeOptionalAttribute(tagWriter, ONSELECT_ATTRIBUTE, getOnselect());
String value = getDisplayString(getBoundValue(), getPropertyEditor());
tagWriter.appendValue(processFieldValue(getName(), value, "textarea"));
tagWriter.appendValue("\r\n" + processFieldValue(getName(), value, "textarea"));
tagWriter.endTag();
return SKIP_BODY;
}
......
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......@@ -121,6 +121,16 @@ public class TextareaTagTests extends AbstractFormTagTests {
assertBlockTagContains(output, "12.34f");
}
@Test
public void firstNewLine() throws Exception {
this.tag.setPath("name");
this.tag.setReadonly(true);
assertEquals(Tag.SKIP_BODY, this.tag.doStartTag());
String output = getOutput();
assertBlockTagContains(output, "\r\nRob");
}
@Override
protected TestBean createTestBean() {
// set up test data
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册