Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Context may be altered by characters in comments #946

Open
zapateo opened this issue Sep 21, 2023 · 0 comments
Open

Context may be altered by characters in comments #946

zapateo opened this issue Sep 21, 2023 · 0 comments
Assignees
Labels
bug Bug: something already implemented does not work as it should InvalidBehavior A valid or not valid code has an invalid behavior at runtime templates Related to the template

Comments

@zapateo
Copy link
Member

zapateo commented Sep 21, 2023

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.

@zapateo zapateo added bug Bug: something already implemented does not work as it should templates Related to the template InvalidBehavior A valid or not valid code has an invalid behavior at runtime labels Sep 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bug: something already implemented does not work as it should InvalidBehavior A valid or not valid code has an invalid behavior at runtime templates Related to the template
Projects
None yet
Development

No branches or pull requests

2 participants