Permalink
Browse files

Fix EZP-26832: Enabling editor causes error on links with "&" (#1278)

1 parent 6d92659 commit 863c3e4b3a2d19cec08f0641697c26f707de86a5 @dpobel dpobel committed on GitHub Feb 3, 2017
@@ -629,7 +629,11 @@ private function isValidXmlTag( $code )
$code .= '/';
}
$code .= '>';
- $code = '<' . str_replace( '<', '&lt;', substr( $code, 1 ) );
+ $code = '<' . str_replace(
+ array( '<', '&' ),
+ array( '&lt;', '&amp;' ),
+ substr( $code, 1 )
+ );
$errorHanding = libxml_use_internal_errors( true );
$simpleXml = simplexml_load_string( $code );
libxml_use_internal_errors( $errorHanding );
@@ -105,4 +105,23 @@ public function testHeaderNoBreak()
self::assertEquals( 1, $header->length );
self::assertEquals( "Franz Ferdinand - Love Illumination", $header->item( 0 )->textContent );
}
+
+ /**
+ * Test for EZP-26832
+ *
+ * & might not be escaped but the user typing some simplified XML and before
+ * the fix for EZP-26832, this broke the XML parsing.
+ *
+ * @link https://jira.ez.no/browse/EZP-26832
+ */
+ public function testParseAttributeWithAmpersand()
+ {
+ $parser = new eZSimplifiedXMLInputParser(0, eZXMLInputParser::ERROR_SYNTAX);
+ $this->assertNotEquals(
+ false,
+ $parser->process(
+ '<link href="http://google.com/?this=that&something=nothing">link</link>'
+ )
+ );
+ }
}

0 comments on commit 863c3e4

Please sign in to comment.