diff --git a/lib/ezi18n/classes/ezchartransform.php b/lib/ezi18n/classes/ezchartransform.php index c165beb4ef4..20250875bdd 100644 --- a/lib/ezi18n/classes/ezchartransform.php +++ b/lib/ezi18n/classes/ezchartransform.php @@ -395,12 +395,10 @@ static function commandUrlCleanup( $text, $charsetName ) $sep = eZCharTransform::wordSeparator(); $sepQ = preg_quote( $sep ); $text = preg_replace( array( "#[^a-zA-Z0-9_!\.-]+#", - "#^[\.]+|[!\.]+$#", # Remove dots at beginning/end "#\.\.+#", # Remove double dots "#[{$sepQ}]+#", # Turn multiple separators into one - "#^[{$sepQ}]+|[{$sepQ}]+$#" ), # Strip separator from beginning/end + "#^[{$sepQ}\.]+|[{$sepQ}!\.]+$#" ), # Strip separator and dot from beginning, strip exclamation mark, dot and separator from end array( $sep, - $sep, $sep, $sep, "" ), @@ -412,7 +410,7 @@ static function commandUrlCleanupIRI( $text, $charsetName ) { // With IRI support we keep all characters except some reserved ones, // they are space, tab, ampersand, semi-colon, forward slash, colon, equal sign, question mark, - // square brackets, parenthesis, plus. + // square brackets, parenthesis, plus, double quote. // // Note: Spaces and tabs are turned into a dash to make it easier for people to // paste urls from the system and have the whole url recognized @@ -422,13 +420,11 @@ static function commandUrlCleanupIRI( $text, $charsetName ) $prepost = " ." . $sepQ; if ( $sep != "-" ) $prepost .= "-"; - $text = preg_replace( array( "#[ \t\\\\%\#&;/:=?\[\]()+]+#", - "#^[\.]+|[!\.]+$#", # Remove dots at beginning/end + $text = preg_replace( array( "#[ \t\\\\%\#&;/:=?\[\]()+\"]+#", "#\.\.+#", # Remove double dots "#[{$sepQ}]+#", # Turn multiple separators into one - "#^[{$prepost}]+|[{$prepost}]+$#" ), + "#^[{$prepost}]+|[!{$prepost}]+$#" ), # Strip "!", dots and separator from beginning/end array( $sep, - $sep, $sep, $sep, "" ), diff --git a/tests/tests/lib/ezi18n/ezchartransform_test.php b/tests/tests/lib/ezi18n/ezchartransform_test.php new file mode 100644 index 00000000000..0338de71f45 --- /dev/null +++ b/tests/tests/lib/ezi18n/ezchartransform_test.php @@ -0,0 +1,52 @@ +setName( "eZCharTransformTests" ); + } + + public function setUp() + { + parent::setUp(); + } + + public function tearDown() + { + parent::tearDown(); + } + + public function testCommandUrlCleanupMultipleSpecialCharsAtEnd() + { + $objectName = 'test."'; + $transformed = eZCharTransform::commandUrlCleanup( $objectName ); + $this->assertEquals( $transformed, 'test' ); + + $objectName = 'te.st."'; + $transformed = eZCharTransform::commandUrlCleanup( $objectName ); + $this->assertEquals( $transformed, 'te.st' ); + + $objectName = '.test!"'; + $transformed = eZCharTransform::commandUrlCleanup( $objectName ); + $this->assertEquals( $transformed, 'test' ); + } + + public function testCommandUrlCleanupIRI() + { + $objectName = '.täst."'; + $transformed = eZCharTransform::commandUrlCleanupIRI( $objectName ); + $this->assertEquals( 'täst', $transformed ); + + $objectName = '.test!"'; + $transformed = eZCharTransform::commandUrlCleanupIRI( $objectName ); + $this->assertEquals( 'test', $transformed ); + } +} diff --git a/tests/tests/lib/ezi18n/suite.php b/tests/tests/lib/ezi18n/suite.php new file mode 100644 index 00000000000..608ac47cb75 --- /dev/null +++ b/tests/tests/lib/ezi18n/suite.php @@ -0,0 +1,22 @@ +setName( "eZFile Test Suite" ); + $this->addTestSuite( 'eZCharTransformTests' ); + } + + public static function suite() + { + return new self(); + } + +}