jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/322834 )

Change subject: Prevent double-encoding of URLs that were output by the 'dot' 
command
......................................................................


Prevent double-encoding of URLs that were output by the 'dot' command

The output of 'dot -Tcmapx' encodes HTML entities in URLs, and because
this is passed straight to ImageMap::render (which then also encodes
these entities) the final output is double-encoded.

This change fixes this for non-mscgen renderers (i.e. only GraphViz,
because 'mscgen -T ismap' does not encode HTML entities in URLs).

Bug: T151294
Change-Id: I31851bfd3a08420eac8b33efd303fb6520370f30
---
M GraphViz_body.php
1 file changed, 10 insertions(+), 0 deletions(-)

Approvals:
  Welterkj: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/GraphViz_body.php b/GraphViz_body.php
index c27134c..17df423 100644
--- a/GraphViz_body.php
+++ b/GraphViz_body.php
@@ -1548,6 +1548,16 @@
                                        'href="[$1 $2]"',
                                        $map );
 
+                               // Decode character references in URLs because 
the map file output by GraphViz
+                               // has already encoded them and we want to pass 
them to ImageMap::render
+                               // unencoded.
+                               $hrefPattern = '~href="([^"]+)"~';
+                               preg_match( $hrefPattern, $map, $matches );
+                               if ( isset( $matches[1] ) ) {
+                                       $decodedHref = 
Sanitizer::decodeCharReferences( $matches[1] );
+                                       $map = preg_replace( $hrefPattern, 
"href=\"$decodedHref\"", $map );
+                               }
+
                                // reorder map lines to the pattern shape name, 
coordinates, URL
                                $map = preg_replace( 
'~.+shape="([^"]+).+href="([^"]+).+coords="([^"]+).+~',
                                        '$1 $3 $2',

-- 
To view, visit https://gerrit.wikimedia.org/r/322834
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I31851bfd3a08420eac8b33efd303fb6520370f30
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/GraphViz
Gerrit-Branch: master
Gerrit-Owner: Samwilson <s...@samwilson.id.au>
Gerrit-Reviewer: Samwilson <s...@samwilson.id.au>
Gerrit-Reviewer: Welterkj <welterkj+...@gmail.com>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to