diff --git a/includes/common.php b/includes/common.php index 95a673b3d5..3a0bf155b0 100644 --- a/includes/common.php +++ b/includes/common.php @@ -492,7 +492,7 @@ function safename($name) function safedescr($descr) { - return safename($descr); + return preg_replace('/[^a-zA-Z0-9,._\-\/\ ]/', ' ', $descr); } function zeropad($num, $length = 2) diff --git a/tests/CommonFunctionsTest.php b/tests/CommonFunctionsTest.php index 99a82e7e30..fd1dea28f0 100644 --- a/tests/CommonFunctionsTest.php +++ b/tests/CommonFunctionsTest.php @@ -77,4 +77,11 @@ class CommonFunctionsTest extends \PHPUnit_Framework_TestCase $this->assertTrue(ends_with($data, array('this', 'tesTing', 'no'), true)); $this->assertFalse(ends_with($data, array('this', 'Test'), true)); } + + public function testRrdDescriptions() + { + $data = 'Toner S/N:CRUM-1'; + + $this->assertEquals('Toner S/N CRUM-1', safedescr($data)); + } }