<?php if (!defined('PmWiki')) exit(); /** FixURL - Encode special characters in link addresses Written by (c) Petko Yotov 2011 www.pmwiki.org/Petko This text is written for PmWiki; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. See pmwiki.php for full details and lack of warranty. */ # Version date $RecipeInfo['FixURL']['Version'] = '20150722'; SDVA($GUIButtons, array( 'fixurl'=>array( 2000, '', '', '', '<img src=\'$GUIButtonDirUrlFmt/fixurl.png\' ' .'alt=\'$[FixUrl]\' title=\'$[Encode special characters in URL link addresses]\' ' .'onclick=\'insMarkup(FixSelectedURL);\'/>' ))); $HTMLHeaderFmt['fixurl']= <<<EOF <script type='text/javascript'><!-- // FixSelectedURL() by Petko Yotov, www.pmwiki.org/Petko function FixSelectedURL(str) { var rx = new RegExp("[ <>\\"{}|\\\\\\\\^`()\\\\[\\\\]']", 'g'); str = str.replace(rx, function(a){ return '%'+a.charCodeAt(0).toString(16); }); return str; } //--></script> EOF;