mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
BUGFIX Ensure TextareaField template is encoding characters correctly
This commit is contained in:
parent
9e548f501e
commit
19e9b19a1a
@ -1,5 +1,5 @@
|
||||
<% if isReadonly %>
|
||||
<span id="$ID" class="textarea readonly$extraClass"><% if Value %>$Value<% else %><em>(<% _t('NONE', 'none') %>)</em><% end_if %></span>
|
||||
<span id="$ID" class="readonly$extraClass" name="$Name"><% if Value %>$Value<% else %><em>(<% _t('NONE', 'none') %>)</em><% end_if %></span>
|
||||
<% else %>
|
||||
<textarea id="$ID" class="textarea$extraClass" name="$Name" rows="$Rows" cols="$Cols"<% if isDisabled %> disabled<% end_if %>></textarea>
|
||||
<textarea id="$ID" class="textarea$extraClass" name="$Name" rows="$Rows" cols="$Cols"<% if isDisabled %> disabled<% end_if %>>$Value</textarea>
|
||||
<% end_if %>
|
@ -6,43 +6,21 @@ class TextareaFieldTest extends SapphireTest {
|
||||
* Quick smoke test to ensure that text is being encoded properly.
|
||||
*/
|
||||
function testTextEncoding() {
|
||||
$inputText = "This is my <text>
|
||||
What's on a new-line?
|
||||
These are some unicodes: äöü&<>";
|
||||
|
||||
$inputText = "This is my <text>These are some unicodes: äöü&<>";
|
||||
$field = new TextareaField("Test", "Test", 5, 20);
|
||||
$field->setValue($inputText);
|
||||
|
||||
$this->assertEquals(<<<HTML
|
||||
<textarea id="Test" name="Test" rows="5" cols="20">This is my <text>
|
||||
What's on a new-line?
|
||||
These are some unicodes: äöü&<></textarea>
|
||||
HTML
|
||||
, $field->Field());
|
||||
$this->assertContains('This is my <text>These are some unicodes: äöü&<>', $field->Field());
|
||||
}
|
||||
|
||||
/**
|
||||
* Quick smoke test to ensure that text is being encoded properly in readonly fields.
|
||||
*/
|
||||
function testReadonlyTextEncoding() {
|
||||
$inputText = "This is my <text>
|
||||
What's on a new-line?
|
||||
These are some unicodes: äöü&<>";
|
||||
|
||||
$inputText = "This is my <text>These are some unicodes: äöü&<>";
|
||||
$field = new TextareaField("Test", "Test", 5, 20);
|
||||
$field = $field->performReadonlyTransformation();
|
||||
|
||||
// Make sure that the field is smart enough to have its value set after being made readonly
|
||||
$field->setValue($inputText);
|
||||
$this->assertEquals(<<<HTML
|
||||
<span id="Test" class="readonly" name="Test" readonly="readonly">This is my <text><br />
|
||||
What's on a new-line?<br />
|
||||
These are some unicodes: äöü&<></span>
|
||||
<input type="hidden" name="Test" value="This is my &lt;text&gt;<br />
|
||||
What's on a new-line?<br />
|
||||
These are some unicodes: &auml;&ouml;&uuml;&amp;&lt;&gt;" />
|
||||
HTML
|
||||
, $field->Field());
|
||||
$this->assertContains('This is my <text>These are some unicodes: äöü&<>', $field->Field());
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user