Skip to content

Commit

Permalink
fix(textfield): target ticket title need html encoding
Browse files Browse the repository at this point in the history
GLPI 10.0.7 HTML encodes data in ticket's title
  • Loading branch information
btry committed Jun 19, 2023
1 parent 8aaec8a commit 1b71d65
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
6 changes: 1 addition & 5 deletions inc/field/textfield.class.php
Expand Up @@ -108,11 +108,7 @@ public function getValueForDesign(): string {
}

public function getValueForTargetText($domain, $richText): ?string {
if ($richText) {
return Sanitizer::encodeHtmlSpecialChars($this->value);
}

return $this->value;
return Sanitizer::encodeHtmlSpecialChars($this->value);
}

public function moveUploads() {
Expand Down
2 changes: 1 addition & 1 deletion tests/3-unit/GlpiPlugin/Formcreator/Field/TextField.php
Expand Up @@ -401,7 +401,7 @@ public function providerGetValueForTargetText() {
'question' => $this->getQuestion(),
'value' => '"><img src=x onerror="alert(1337)" x=x>',
'expected' => true,
'expectedValue' => '"><img src=x onerror="alert(1337)" x=x>',
'expectedValue' => '"&#62;&#60;img src=x onerror="alert(1337)" x=x&#62;',
],
];
}
Expand Down

0 comments on commit 1b71d65

Please sign in to comment.