Skip to content

Filter arg parser trims whitespace inside quoted strings #332

Description

@ErickXavier

_parseFilterArgs in src/evaluate.js applies .trim() to the parsed content of quoted filter arguments, stripping meaningful leading and trailing whitespace.

Reproduction:

<div state="{ items: ['x', 'y', 'z'] }">
  <span bind="items | join:' - '"></span>
  <!-- Expected: x - y - z -->
  <!-- Actual:   x-y-z     -->
</div>

Root cause: Lines 1865 and 1872 of src/evaluate.js call current.trim() after the content has already been correctly extracted from between quote characters. The trim is appropriate for unquoted values (removing incidental HTML attribute whitespace) but incorrect for quoted values (destroying intentional whitespace).

Impact: Any filter argument with leading or trailing whitespace inside quotes is affected. This includes the documented join:', ' example in docs/md/filters.md, which promises a, b, c but actually produces a,b,c. Affects both the compiled path (_compileFilterSpec_parseFilterArgs) and the interpreted path (_applyFilter_parseFilterArgs).

Fix: Track whether the current argument was parsed from a quoted string. Skip trim() for quoted arguments; apply it only to unquoted values. Existing tests only cover interior spaces (__tests__/core.test.js:741), so a leading/trailing-whitespace case should be added.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions