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

Radu Cotescu updated SLING-6094:
--------------------------------
    Description: 
HTL can generate invalid Java code by using user-supplied input or markup 
elements as fragments for variable names.

This could happen with the {{data-sly-attribute}} plug-in, when the value is a 
map and the plug-in has to analyse previously defined attributes:

{code:html}
<img src="" v-bind:src="abc" data-sly-attribute="${logic.hello}" />
{code}

or with user-defined script variable names:


  was:
If you have a tag with an attribute name that has a colon and we use 
data-sly-attribute with a map variance (value is a map), we get a NPE and a 
cryptic stack trace.


h3. sample.html
{code}
<div data-sly-use.logic="test.js">
    ${logic.hello.hello}
    <img src="" v-bind:src="abc" data-sly-attribute="${logic.hello}" />
</div>
{code}

h3. test.js
{code}
use(function () {
    var message = "Hello World";

    return {
        // anything exposed here can be used inside your template
        hello: {hello: message}
    };
});
{code}

h3. Stack Trace

{code}
04.10.2016 14:47:55.460 *ERROR* [0:0:0:0:0:0:0:1 [1475585275441] GET 
/content/sample.html HTTP/1.1] 
org.apache.sling.engine.impl.SlingRequestProcessorImpl service: Uncaught 
SlingException
org.apache.sling.scripting.sightly.impl.compiler.CompilerException: 
java.lang.NullPointerException
        at 
org.apache.sling.scripting.sightly.impl.compiler.SightlyJavaCompilerService.compileSource(SightlyJavaCompilerService.java:148)
        at 
org.apache.sling.scripting.sightly.impl.engine.UnitLoader.createUnit(UnitLoader.java:101)
        at 
org.apache.sling.scripting.sightly.impl.engine.SightlyScriptEngine.evaluateScript(SightlyScriptEngine.java:91)
        at 
org.apache.sling.scripting.sightly.impl.engine.SightlyScriptEngine.eval(SightlyScriptEngine.java:78)
        at 
org.apache.sling.scripting.core.impl.DefaultSlingScript.call(DefaultSlingScript.java:388)
        at 
org.apache.sling.scripting.core.impl.DefaultSlingScript.eval(DefaultSlingScript.java:184)
... shortened
{code}


> HTL can generate invalid Java code by using user-supplied input
> ---------------------------------------------------------------
>
>                 Key: SLING-6094
>                 URL: https://issues.apache.org/jira/browse/SLING-6094
>             Project: Sling
>          Issue Type: Bug
>          Components: Scripting
>    Affects Versions: Scripting Sightly Engine 1.0.18
>            Reporter: Mark J. Becker
>            Assignee: Radu Cotescu
>             Fix For: Scripting HTL Java Compiler 1.0.2, Scripting HTL Engine 
> 1.0.22
>
>
> HTL can generate invalid Java code by using user-supplied input or markup 
> elements as fragments for variable names.
> This could happen with the {{data-sly-attribute}} plug-in, when the value is 
> a map and the plug-in has to analyse previously defined attributes:
> {code:html}
> <img src="" v-bind:src="abc" data-sly-attribute="${logic.hello}" />
> {code}
> or with user-defined script variable names:



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to