<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[PHP Labware forum — Stripping away <script>*</script> and <style>*</style> blocks]]></title>
		<link>https://www.bioinformatics.org/phplabware/forum/viewtopic.php?id=306</link>
		<atom:link href="https://www.bioinformatics.org/phplabware/forum/extern.php?action=feed&amp;tid=306&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[The most recent posts in Stripping away <script>*</script> and <style>*</style> blocks.]]></description>
		<lastBuildDate>Mon, 14 Nov 2016 19:49:50 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: Stripping away <script>*</script> and <style>*</style> blocks]]></title>
			<link>https://www.bioinformatics.org/phplabware/forum/viewtopic.php?pid=871#p871</link>
			<description><![CDATA[<p>Sorry about the delay in posting my reply.</p><p>You are right – it is not possible to have htmLawed set to remove element content. The &quot;keep_bad&quot; config. parameter primarily concerns tag content (&quot;&lt;tag ...&gt;&quot; and &quot;&lt;/tag&gt;&quot;) and its settings dictate the handling of disallowed tags (remove, neutralize, etc.).</p><p>During tag balancing, enabled by default with config. parameter &quot;balance&quot;, htmLawed checks if the plain-text element content following the opening tag, and any neutralized opening tag (which now is plain text) is allowed in the parent element; if not, it is removed if &quot;keep_bad&quot; is appropriately set.</p><p>It is possible for htmLawed to get the functionality that your posting indicates, but I have avoided including it because of the complicated scenarios it may need to deal with (such as element content containing more elements).</p><p>For the current version of htmLawed, the best way I can suggest to handle the cases that you mention is to remove the &quot;script&quot; or &quot;style&quot; elements with a separate PHP function call. E.g.<br /></p><div class="codebox"><pre class="prettyprint"><code>$temp = htmLawed($in ...);
$out = preg_replace(&#039;`&lt;((script)|(style))[^&gt;]*&gt;[^&lt;]*&lt;/\1&gt;`si&#039;, $temp);</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (patnaik)]]></author>
			<pubDate>Mon, 14 Nov 2016 19:49:50 +0000</pubDate>
			<guid>https://www.bioinformatics.org/phplabware/forum/viewtopic.php?pid=871#p871</guid>
		</item>
		<item>
			<title><![CDATA[Stripping away <script>*</script> and <style>*</style> blocks]]></title>
			<link>https://www.bioinformatics.org/phplabware/forum/viewtopic.php?pid=869#p869</link>
			<description><![CDATA[<p>I&#039;m trying to strip away script and style code blocks entirely.</p><p>HTML in:</p><div class="codebox"><pre class="prettyprint"><code>&lt;style type=&quot;text/css&quot;&gt;
.foo { color:blue; }
&lt;/style&gt;
&lt;div class=&quot;foo&quot;&gt;hello world&lt;/div&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
    if (true) {
        var foo = &#039;bar&#039;;
    }
&lt;/script&gt;</code></pre></div><p>Tried with this htmlLawed:</p><div class="codebox"><pre class="prettyprint"><code>$htmlOut = htmLawed(
    $htmlIn,
    array(
        &#039;comment&#039; =&gt; 1,
        &#039;safe&#039; =&gt; 1,
    )
);</code></pre></div><p>What I&#039;d like:</p><div class="codebox"><pre class="prettyprint"><code>&lt;div class=&quot;foo&quot;&gt;hello world&lt;/div&gt;</code></pre></div><p>What I get instead:</p><div class="codebox"><pre class="prettyprint"><code>.foo { color:blue; }

&lt;div class=&quot;foo&quot;&gt;hello world&lt;/div&gt;

    if (true) {
        var foo = &#039;bar&#039;;
    }</code></pre></div><p>I&#039;m not sure it is even possibile. Tried also all keep_bad possibile values with no luck.</p>]]></description>
			<author><![CDATA[null@example.com (DrLightman)]]></author>
			<pubDate>Thu, 03 Nov 2016 13:48:14 +0000</pubDate>
			<guid>https://www.bioinformatics.org/phplabware/forum/viewtopic.php?pid=869#p869</guid>
		</item>
	</channel>
</rss>
