Skip to content

"contains" filter behaves improperly with NUL characters #1732

@wchargin

Description

@wchargin

Description

The contains(needle) filter does not match an input that contains
needle only after a NUL character. In JSON (and Unicode), NUL is a
normal character, not an end-of-string marker.

To reproduce

jqplay link: https://jqplay.org/s/ufUZAtLeHn

Filter: [contains("x"), contains("x\u0000"), contains("x\u0000y"), contains("y")]

JSON: "x\u0000y"

Expected behavior

Output should be [true, true, true, true].

Actual behavior

Output is [true, true, true, false].

Environment

  • OS and Version: Linux Mint 18.2 (Ubuntu 16.04)
  • jq-1.5-1-a5b5cbe

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions