Skip to content

Context may be altered by characters in comments #946

@zapateo

Description

@zapateo

Currently, when rendering Javascript, characters in comments (as ', for example) may change the context, resulting in a bad rendering of the Scriggo template.

Consider this:

<script>

    // it is ok
    
    {% x := "hello hey" %}

    if ({{ x }}) { }   // AAA
    if ('{{ x }}') { } // CCC
    if ("{{ x }}") { } // DDD

</script>

this is – correctly – rendered as:

<script>

    // it is ok
    

    if ("hello hey") { }   // AAA
    if ('hello hey') { } // CCC
    if ("hello hey") { } // DDD

</script>

As you may note, the strings are quoted correctly, so the bug does not show here.

In this case, instead, the comment contains the character '. So, Scriggo changes the context, and thus the template:

<script>

    // it's bad
    
    {% x := "hello hey" %}

    if ({{ x }}) { }   // AAA
    if ('{{ x }}') { } // CCC
    if ("{{ x }}") { } // DDD

</script>

is – incorrectly – rendered as:

<script>

    // it's bad
    

    if (hello hey) { }   // AAA
    if ('"hello hey"') { } // CCC
    if ("hello hey") { } // DDD

</script>

As you may note, the strings are not quoted correctly.

So, this behavior should be investigated and corrected.

Metadata

Metadata

Assignees

Labels

InvalidBehaviorA valid or not valid code has an invalid behavior at runtimebugBug: something already implemented does not work as it shouldtemplatesRelated to the template

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions