Commit eea3cd54 authored by Côme Chilliet's avatar Côme Chilliet
Browse files

Fixes #3587 Replacing CRLF by LF in TextAreaAttribute and FileTextAreaAttribute

Showing with 23 additions and 3 deletions
+23 -3
......@@ -149,14 +149,21 @@ class Attribute
$this->manageAttributes($this->value);
}
/*! \brief Set the postValue */
function setPostValue ($value)
{
if ($this->isVisible()) {
$this->postValue = $value;
$this->postValue = $this->fixPostValue($value);
$this->manageAttributes($this->postValue);
}
}
/*! \brief In case a treatment is needed on POST content */
function fixPostValue ($value)
{
return $value;
}
/*! \brief Reset this attribute to its default value
*/
function resetToDefault ()
......@@ -864,6 +871,12 @@ class StringAttribute extends Attribute
return $this->renderAcl($display);
}
function fixPostValue ($value)
{
/* Replace CRLF by LF, to avoid non-ASCII chars in multiline values (mainly useful for textarea) */
return str_replace(array("\r\n", "\r"), "\n", $value);
}
function check ()
{
$error = parent::check();
......@@ -1614,10 +1627,11 @@ class FileAttribute extends Attribute
*/
function readFile($handle)
{
$this->postValue = fread($handle, 1024);
$postValue = fread($handle, 1024);
while (!feof($handle)) {
$this->postValue .= fread($handle, 1024);
$postValue .= fread($handle, 1024);
}
$this->setPostValue($postValue);
@fclose($handle);
}
......@@ -1758,6 +1772,12 @@ class FileTextAreaAttribute extends FileDownloadAttribute
return $this->renderAcl($display).parent::renderFormInput();
}
function fixPostValue ($value)
{
/* Replace CRLF by LF, to avoid non-ASCII chars */
return str_replace(array("\r\n", "\r"), "\n", $value);
}
public function htmlIds()
{
$ids = parent::htmlIds();
......
  • bmortier @bmortier

    mentioned in issue #1196 (closed)

    By Jonathan Swaelens on 2017-09-02T15:16:44 (imported from GitLab)

    ·

    mentioned in issue #1196 (closed)

    By Jonathan Swaelens on 2017-09-02T15:16:44 (imported from GitLab)

    Toggle commit list
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment