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

Improper quote formatting in HubL functions inside of is_json=True block attributes. #67

Open
evelynn-causemic opened this issue Mar 7, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@evelynn-causemic
Copy link

Description

When using a function or filter that takes a string inside of a JSON-formatted widget block attribute, all quotes are changed to double-quotes, terminating the string prematurely and causing the function to fail.

Expected behavior

A mixture of double quotes, single quotes, and escaped quotes would be used based on level of quote nesting.

To Reproduce

Original Source Code:
Here, the string passed into get_asset_url() is wrapped in single quotes, and the function resolves as expected.

{% widget_attribute "facebook" is_json=True %}
  {
    "custom_link_format": "", 
    "enabled": true, 
    "network": "facebook", 
    "img_src": "{{ get_asset_url('../images/icons/facebook.svg') }}"
  }
{% end_widget_attribute %}

Formatted Source Code:
After formatting, the single quotes are replaced with double quotes, setting the value of img_src to "{{ get_asset_url(".

{% widget_attribute "facebook"
            is_json=True %}{"custom_link_format": "", "enabled": true,
            "network": "facebook", "img_src": "{{ get_asset_url("../images/icons/facebook.svg") }}"}
{% end_widget_attribute %}

Additional context

These quotes are force-reformatted on every save, even if manually changed back. With current documented functionality, the only way to prevent this formatting is to prevent formatting for the entire document.

@evelynn-causemic evelynn-causemic added the bug Something isn't working label Mar 7, 2023
@bmatto
Copy link

bmatto commented Mar 10, 2023

@evelynn-causemic Thank you for the report! We'll take a look.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants