diff --git a/Core/Model/EstadoDocumento.php b/Core/Model/EstadoDocumento.php index 25e82b5d54..47dd2e5b76 100644 --- a/Core/Model/EstadoDocumento.php +++ b/Core/Model/EstadoDocumento.php @@ -138,7 +138,13 @@ public static function tableName(): string public function test(): bool { - $this->nombre = $this->toolBox()->utils()->noHtml($this->nombre); + // escapamos el html + $this->generadoc = self::toolBox()::utils()::noHtml($this->generadoc); + $this->icon = self::toolBox()::utils()::noHtml($this->icon); + $this->nombre = self::toolBox()::utils()::noHtml($this->nombre); + $this->tipodoc = self::toolBox()::utils()::noHtml($this->tipodoc); + + // Comprobamos que el nombre no esté vacío if (empty($this->nombre) || empty($this->tipodoc)) { return false; } diff --git a/Test/Core/Model/EstadoDocumentoTest.php b/Test/Core/Model/EstadoDocumentoTest.php index 13e71fb090..48812e08a3 100644 --- a/Test/Core/Model/EstadoDocumentoTest.php +++ b/Test/Core/Model/EstadoDocumentoTest.php @@ -1,7 +1,7 @@ + * Copyright (C) 2021-2022 Carlos Garcia Gomez * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as @@ -45,6 +45,26 @@ public function testCreateNewStatus() $this->assertTrue($status->delete(), 'estado-documento-cant-delete'); } + public function testHtmlOnFields() + { + // creamos un estado con html en los campos + $status = new EstadoDocumento(); + $status->nombre = ''; + $status->tipodoc = ''; + $status->generadoc = ''; + $status->icon = ''; + $this->assertTrue($status->save(), 'estado-documento-cant-save'); + + // comprobamos que el html se ha escapado + $this->assertEquals('<test>', $status->nombre, 'estado-documento-html-not-escaped'); + $this->assertEquals('<test>', $status->tipodoc, 'estado-documento-html-not-escaped'); + $this->assertEquals('<test>', $status->generadoc, 'estado-documento-html-not-escaped'); + $this->assertEquals('<test>', $status->icon, 'estado-documento-html-not-escaped'); + + // eliminamos + $this->assertTrue($status->delete(), 'estado-documento-cant-delete'); + } + public function testCreateDefaultStatus() { // get the initial default count