<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: A View Stream with Zend_View</title>
	<atom:link href="http://akrabat.com/zend-framework/a-view-stream-with-zend_view/feed/" rel="self" type="application/rss+xml" />
	<link>http://akrabat.com/zend-framework/a-view-stream-with-zend_view/</link>
	<description>Developing PHP software in the Real World, by Rob Allen</description>
	<lastBuildDate>Wed, 08 Feb 2012 14:36:57 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Pieter Vogelaar</title>
		<link>http://akrabat.com/zend-framework/a-view-stream-with-zend_view/#comment-78278</link>
		<dc:creator>Pieter Vogelaar</dc:creator>
		<pubDate>Fri, 16 Sep 2011 09:15:14 +0000</pubDate>
		<guid isPermaLink="false">http://akrabat.com/2008/02/05/a-view-stream-with-zend_view/#comment-78278</guid>
		<description>Over at the PiKe project we build a custom stream wrapper that automatically escapes all view variables, with a MINIMAL performance hit! You can still get the RAW value with:



Notice the &quot;~&quot; character. Checkout http://code.google.com/p/php-pike/wiki/Pike_View_Stream

I know you said that you want to avoid &quot;tricky ways like output buffering and PREG replacing *.phtml files.&quot;, but I still think it&#039;s a very neat way to fix auto escaping in Zend Framework 1.</description>
		<content:encoded><![CDATA[<p>Over at the PiKe project we build a custom stream wrapper that automatically escapes all view variables, with a MINIMAL performance hit! You can still get the RAW value with:</p>
<p>Notice the "~" character. Checkout <a href="http://code.google.com/p/php-pike/wiki/Pike_View_Stream" rel="nofollow">http://code.google.com/p/php-pike/wiki/Pike_View_Stream</a></p>
<p>I know you said that you want to avoid "tricky ways like output buffering and PREG replacing *.phtml files.", but I still think it's a very neat way to fix auto escaping in Zend Framework 1.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Joe Devon</title>
		<link>http://akrabat.com/zend-framework/a-view-stream-with-zend_view/#comment-32427</link>
		<dc:creator>Joe Devon</dc:creator>
		<pubDate>Sun, 28 Mar 2010 00:24:07 +0000</pubDate>
		<guid isPermaLink="false">http://akrabat.com/2008/02/05/a-view-stream-with-zend_view/#comment-32427</guid>
		<description>I grant you that&#039;s a bad example, heh heh, what I meant is, &lt;?= is the same as &lt;?php echo, which can go multi-line legitimately. 

If you&#039;re trying to improve security then a robust solution would be preferred, which would require a parser instead of regex...

But I suppose this&#039;ll do the trick if you make sure you keep it to a one liner. 

For your readers, I&#039;ll link to a cool thread (that you participated in) about how escaping is being planned for #ZF 2.0:
http://framework.zend.com/wiki/display/ZFDEV2/Zend_View+2.0

</description>
		<content:encoded><![CDATA[<p>I grant you that's a bad example, heh heh, what I meant is, &lt;?= is the same as &lt;?php echo, which can go multi-line legitimately. </p>
<p>If you're trying to improve security then a robust solution would be preferred, which would require a parser instead of regex...</p>
<p>But I suppose this'll do the trick if you make sure you keep it to a one liner. </p>
<p>For your readers, I'll link to a cool thread (that you participated in) about how escaping is being planned for #ZF 2.0:<br />
<a href="http://framework.zend.com/wiki/display/ZFDEV2/Zend_View+2.0" rel="nofollow">http://framework.zend.com/wiki/display/ZFDEV2/Zend_View+2.0</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rob...</title>
		<link>http://akrabat.com/zend-framework/a-view-stream-with-zend_view/#comment-32420</link>
		<dc:creator>Rob...</dc:creator>
		<pubDate>Sat, 27 Mar 2010 17:33:36 +0000</pubDate>
		<guid isPermaLink="false">http://akrabat.com/2008/02/05/a-view-stream-with-zend_view/#comment-32420</guid>
		<description>Joe,

I expect it would break :)  But then I wouldn&#039;t be impressed if I saw that code in a view template anyway!

Rob...</description>
		<content:encoded><![CDATA[<p>Joe,</p>
<p>I expect it would break :)  But then I wouldn't be impressed if I saw that code in a view template anyway!</p>
<p>Rob...</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Joe Devon</title>
		<link>http://akrabat.com/zend-framework/a-view-stream-with-zend_view/#comment-32419</link>
		<dc:creator>Joe Devon</dc:creator>
		<pubDate>Sat, 27 Mar 2010 17:28:18 +0000</pubDate>
		<guid isPermaLink="false">http://akrabat.com/2008/02/05/a-view-stream-with-zend_view/#comment-32419</guid>
		<description>Nice thought but personally not a huge fan of this approach, feels like it&#039;s using regex where a parser is more appropriate... particularly as you&#039;re trying to solve a security issue, where arcane, missed details are often where holes are exploited...

P.S. I didn&#039;t look much at the regex but I&#039;m curious, how would you want to handle something like this?:

&lt; ?= @var; @var2 ?&gt;</description>
		<content:encoded><![CDATA[<p>Nice thought but personally not a huge fan of this approach, feels like it's using regex where a parser is more appropriate... particularly as you're trying to solve a security issue, where arcane, missed details are often where holes are exploited...</p>
<p>P.S. I didn't look much at the regex but I'm curious, how would you want to handle something like this?:</p>
<p>< ?= @var; @var2 ?></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rob...</title>
		<link>http://akrabat.com/zend-framework/a-view-stream-with-zend_view/#comment-20856</link>
		<dc:creator>Rob...</dc:creator>
		<pubDate>Fri, 28 Mar 2008 08:06:08 +0000</pubDate>
		<guid isPermaLink="false">http://akrabat.com/2008/02/05/a-view-stream-with-zend_view/#comment-20856</guid>
		<description>Dinoboff,

Very interesting, Thanks!

Regards,

Rob...</description>
		<content:encoded><![CDATA[<p>Dinoboff,</p>
<p>Very interesting, Thanks!</p>
<p>Regards,</p>
<p>Rob...</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dinoboff</title>
		<link>http://akrabat.com/zend-framework/a-view-stream-with-zend_view/#comment-20852</link>
		<dc:creator>Dinoboff</dc:creator>
		<pubDate>Fri, 28 Mar 2008 04:42:57 +0000</pubDate>
		<guid isPermaLink="false">http://akrabat.com/2008/02/05/a-view-stream-with-zend_view/#comment-20852</guid>
		<description>Here a version with caching:
http://code.google.com/p/simple-php-template/source/browse/trunk/src/library/Spt/Stream/View.php

It doesn&#039;t add the escape method. A subclass of Zend_View escape the variables by default instead.</description>
		<content:encoded><![CDATA[<p>Here a version with caching:<br />
<a href="http://code.google.com/p/simple-php-template/source/browse/trunk/src/library/Spt/Stream/View.php" rel="nofollow">http://code.google.com/p/simple-php-template/source/browse/trunk/src/library/Spt/Stream/View.php</a></p>
<p>It doesn't add the escape method. A subclass of Zend_View escape the variables by default instead.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dinoboff</title>
		<link>http://akrabat.com/zend-framework/a-view-stream-with-zend_view/#comment-20841</link>
		<dc:creator>Dinoboff</dc:creator>
		<pubDate>Thu, 27 Mar 2008 16:55:36 +0000</pubDate>
		<guid isPermaLink="false">http://akrabat.com/2008/02/05/a-view-stream-with-zend_view/#comment-20841</guid>
		<description>Finally, about the ternary operator:

&lt;?= @$var ? @$var : &#039;-unknown-&#039;; ?&gt;
&lt;?= $var ? $var : &#039;-unknown-&#039;; ?&gt; 

become:

&lt;?php echo $this-&gt;escape($this-&gt;var ? $this-&gt;var : &#039;-unknown-&#039;); ?&gt;
&lt;?php echo $this-&gt;escape($var ? $var : &#039;-unknown-&#039;); ?&gt;

Even if it is not really what you write, isn&#039;t it valid php?</description>
		<content:encoded><![CDATA[<p>Finally, about the ternary operator:</p>
<p>&lt;?= @$var ? @$var : '-unknown-'; ?&gt;<br />
&lt;?= $var ? $var : '-unknown-'; ?&gt; </p>
<p>become:</p>
<p>&lt;?php echo $this-&gt;escape($this-&gt;var ? $this-&gt;var : '-unknown-'); ?&gt;<br />
&lt;?php echo $this-&gt;escape($var ? $var : '-unknown-'); ?&gt;</p>
<p>Even if it is not really what you write, isn't it valid php?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dinoboff</title>
		<link>http://akrabat.com/zend-framework/a-view-stream-with-zend_view/#comment-20840</link>
		<dc:creator>Dinoboff</dc:creator>
		<pubDate>Thu, 27 Mar 2008 16:40:46 +0000</pubDate>
		<guid isPermaLink="false">http://akrabat.com/2008/02/05/a-view-stream-with-zend_view/#comment-20840</guid>
		<description>We also need to escape result of functions:

$find = &#039;/&lt;\?=\s*([^;]*);?\s*\?&gt;/&#039;;
$replace = &quot;&lt;?php echo \$this-&gt;escape($1); ?&gt;&quot;;
$this-&gt;data = preg_replace($find, $replace, $this-&gt;data);</description>
		<content:encoded><![CDATA[<p>We also need to escape result of functions:</p>
<p>$find = '/&lt;\?=\s*([^;]*);?\s*\?&gt;/';<br />
$replace = &quot;&lt;?php echo \$this-&gt;escape($1); ?&gt;&quot;;<br />
$this-&gt;data = preg_replace($find, $replace, $this-&gt;data);</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dinoboff</title>
		<link>http://akrabat.com/zend-framework/a-view-stream-with-zend_view/#comment-20839</link>
		<dc:creator>Dinoboff</dc:creator>
		<pubDate>Thu, 27 Mar 2008 16:33:56 +0000</pubDate>
		<guid isPermaLink="false">http://akrabat.com/2008/02/05/a-view-stream-with-zend_view/#comment-20839</guid>
		<description>Try again...
$find = &#039;/&lt;\?=\s*(\$[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)\s*;?\s*\?&gt;/&#039;;
$replace = &quot;&lt;?php echo \$this-&gt;escape($1); ?&gt;&quot;;
$this-&gt;data = preg_replace($find, $replace, $this-&gt;data);</description>
		<content:encoded><![CDATA[<p>Try again...<br />
$find = '/&lt;\?=\s*(\$[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)\s*;?\s*\?&gt;/';<br />
$replace = &quot;&lt;?php echo \$this-&gt;escape($1); ?&gt;&quot;;<br />
$this-&gt;data = preg_replace($find, $replace, $this-&gt;data);</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dinoboff</title>
		<link>http://akrabat.com/zend-framework/a-view-stream-with-zend_view/#comment-20838</link>
		<dc:creator>Dinoboff</dc:creator>
		<pubDate>Thu, 27 Mar 2008 16:31:05 +0000</pubDate>
		<guid isPermaLink="false">http://akrabat.com/2008/02/05/a-view-stream-with-zend_view/#comment-20838</guid>
		<description>Nevermind, I had to test the solution to understand the details.

ps: make it to work I had to use the following regex:
&lt;pre class=&quot;phpcode&quot;&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;&lt;br /&gt;$find&#160;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;=&#160;&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&#039;//&#039;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;;&lt;br /&gt;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$replace&#160;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;=&#160;&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&quot;escape($1);&#160;?&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;;&lt;br /&gt;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$this&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;-&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;data&#160;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;=&#160;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;preg_replace&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$find&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;,&#160;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$replace&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;,&#160;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$this&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;-&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;data&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;);&lt;/span&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

The regex for a viriable name is from http://www.php.net/language.variables</description>
		<content:encoded><![CDATA[<p>Nevermind, I had to test the solution to understand the details.</p>
<p>ps: make it to work I had to use the following regex:</p>
<pre class="phpcode"><span style="color: #0000BB">
$find&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">'//'</span><span style="color: #007700">;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$replace&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">"escape($1);&nbsp;?&gt;"</span><span style="color: #007700">;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">data&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">preg_replace</span><span style="color: #007700">(</span><span style="color: #0000BB">$find</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$replace</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">data</span><span style="color: #007700">);</span>
</pre>
<p>The regex for a viriable name is from <a href="http://www.php.net/language.variables" rel="nofollow">http://www.php.net/language.variables</a></p>
]]></content:encoded>
	</item>
</channel>
</rss>

