You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@velocity.apache.org by "Michael Osipov (JIRA)" <ji...@apache.org> on 2018/01/07 15:33:00 UTC

[jira] [Closed] (VELOCITY-749) ReferenceInsertionEventHandler called "to often"/need more configuration settings

     [ https://issues.apache.org/jira/browse/VELOCITY-749?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Michael Osipov closed VELOCITY-749.
-----------------------------------

> ReferenceInsertionEventHandler called "to often"/need more configuration settings
> ---------------------------------------------------------------------------------
>
>                 Key: VELOCITY-749
>                 URL: https://issues.apache.org/jira/browse/VELOCITY-749
>             Project: Velocity
>          Issue Type: Bug
>    Affects Versions: 1.6.2
>            Reporter: Marco Rothe
>            Priority: Minor
>
> I use the EscapeXmlReference (ReferenceInsertionEventHandler implementation) in our projects to produce valid XHTML.
> But I works not as expected in some situations:
> Given the reference $test as 'Me & Co. Ltd' (for example from context) will output as 
> Me &amp; Co. Ltd 
> correctly after the EscapeXmlReference.
> But if we enrich the $test reference with some other string before output (#set($test = "* $test *")) we got 
> * Me &amp;amp; Co. Ltd *  
> and not  * Me &amp; Co. Ltd * as output!
> This is because the EscapeReference handler was called two times. First on the (internal) set directive (Me & Co. Ltd -> Me &amp; Co. Ltd), second on the real output of $test to the stream (* Me &amp; Co. Ltd *->  * Me &amp;amp; Co. Ltd *). 
> The javadoc of ReferenceInsertionEventHandler says "Reference 'Stream insertion' event handler.  Called with object  that will be inserted into stream via value.toString()." 
> "inserted  into stream" means to me  into the real output stream of the template merge, not into internal substreams. So I believe it's a bug or a least an unexpected behaviour because it produce unpredictable results on string operations.
> So the ReferenceInsertionEventHandler needs the possibility to know if the current insertation is an internal or an real output insertation to be able to react on situations as descripted above.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@velocity.apache.org
For additional commands, e-mail: dev-help@velocity.apache.org