splitbrain / dokuwiki-plugin-graphviz

Create Graphviz graphs from within DokuWiki
http://www.dokuwiki.org/plugin:graphviz
12 stars 15 forks source link

incompatibility with farming technique . single line fix attached #7

Open schplurtz opened 11 years ago

schplurtz commented 11 years ago

Hi,

This plugins in not compatible with farming techniques described in https://www.dokuwiki.org/farms#b_htaccess_based_setup . This technique adds an HTTP GET parametre.

When the doku text is parsed, a cachefilename is computed based on the md5 sum of the graph parametres, and the img URL that contains the parametres is created. When the browser later GETs the image, the farming rewriting rules add the animal=foo parametre to the URL parametre list. Graphviz plugin then computes the md5 out of the parametre list, which just happens to be different from the initial parametre list. Cache file has a different name, is not found; user gets the error image :-(.

This simple patch filters out any unexpected GET parameters in the _imgfile function, making the plugin compatible with the farming technique.

diff -Naur syntax.php.orig syntax.php 
--- syntax.php.orig 2013-04-03 05:41:13.111977071 +0200
+++ syntax.php  2013-04-03 06:08:48.652007895 +0200
@@ -119,6 +119,8 @@
      * Return path to the rendered image on our local system
      */
     function _imgfile($data){
+   // filter out unwanted GET parametres
+   $data=array_intersect_key( $data, array( 'width' => 1, 'height' => 1, 'layout' => 1, 'align' => 1, 'version' => 1, 'md5' => 1 ));
         $cache  = $this->_cachename($data,'png');

         // create the file if needed

/Schplurtz

atisne commented 9 years ago

As reported in https://www.dokuwiki.org/plugin:graphviz#compatibility, the following patch seems also to work:

In syntax.php function _cachename($data,$ext){ unset($data['width']); unset($data['height']); unset($data['align']); +++ unset($data['animal']); return getcachename(join('x',array_values($data)),'.graphviz.'.$ext); }

Don't know which is the best.

schplurtz commented 2 years ago

I did not test anything, but, in june 2022, the animal parameter has been removed from the query string in both DW core and the farmer plugin. So for anyone running DW release Igor or newer, or using a recent version of the farmer plugin, there is no problem anymore.

See. discussion in https://github.com/splitbrain/dokuwiki/issues/3551 . This bug report can be closed.