From e226efe19ae4b72bc78b89ebc2c4747ea160b80d Mon Sep 17 00:00:00 2001 From: Andreas Gohr <andi@splitbrain.org> Date: Sat, 18 Nov 2006 16:43:33 +0100 Subject: [PATCH] hide inline scripts from XML parsers This patch addes some comment magic to inline scripts to hide them from XML parsers (like the W3C CSS validator). darcs-hash:20061118154333-7ad00-c24bc36192080fe34f232c5ec2df3f494993f2fe.gz --- inc/html.php | 26 +++++++++++++------------- inc/template.php | 5 +++++ 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/inc/html.php b/inc/html.php index 85349b633..0871bb501 100644 --- a/inc/html.php +++ b/inc/html.php @@ -6,9 +6,9 @@ * @author Andreas Gohr <andi@splitbrain.org> */ - if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../').'/'); - - require_once(DOKU_INC.'inc/parserutils.php'); +if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../').'/'); +if(!defined('NL')) define('NL',"\n"); +require_once(DOKU_INC.'inc/parserutils.php'); /** * Convenience function to quickly build a wikilink @@ -362,11 +362,11 @@ function html_search(){ } //show progressbar - print '<div class="centeralign" id="dw__loading">'; - print '<script type="text/javascript" charset="utf-8">'; - print 'showLoadBar();'; - print '</script>'; - print "<br /></div>\n"; + print '<div class="centeralign" id="dw__loading">'.NL; + print '<script type="text/javascript" charset="utf-8"><!--//--><![CDATA[//><!--'.NL; + print 'showLoadBar();'.NL; + print '//--><!]]></script>'.NL; + print '<br /></div>'.NL; flush(); //do quick pagesearch @@ -410,9 +410,9 @@ function html_search(){ } //hide progressbar - print '<script type="text/javascript" charset="utf-8">'; - print 'hideLoadBar("dw__loading");'; - print '</script>'; + print '<script type="text/javascript" charset="utf-8"><!--//--><![CDATA[//><!--'.NL; + print 'hideLoadBar("dw__loading");'.NL; + print '//--><!]]></script>'.NL; flush(); } @@ -1102,10 +1102,10 @@ function html_edit($text=null,$include='edit'){ //FIXME: include needed? target="_blank"><?php echo $lang['mediaselect'] ?></a><?php }?></div> <?php if($wr){?> - <script type="text/javascript" charset="utf-8"> + <script type="text/javascript" charset="utf-8"><!--//--><![CDATA[//><!-- <?php /* sets changed to true when previewed */?> textChanged = <?php ($pr) ? print 'true' : print 'false' ?>; - </script> + //--><!]]></script> <span id="spell__action"></span> <div id="spell__suggest"></div> <?php } ?> diff --git a/inc/template.php b/inc/template.php index cf3bf8da0..e9326632d 100644 --- a/inc/template.php +++ b/inc/template.php @@ -278,6 +278,11 @@ function _tpl_metaheaders_action($data){ foreach($inst as $attr){ echo '<',$tag,' ',buildAttributes($attr); if(isset($attr['_data'])){ + if($tag == 'script' && $attr['_data']) + $attr['_data'] = "<!--//--><![CDATA[//><!--\n". + $attr['_data']. + "\n//--><!]]>"; + echo '>',$attr['_data'],'</',$tag,'>'; }else{ echo '/>'; -- GitLab