jekyll: The where filter fails on values with spaces in them


  • I am on (or have tested on) macOS 10.11.6

  • It was another bug.

My Reproduction Steps

Using Jekyll 3.2.1 with no error output.

I got a json file in the _data folder named test.json with the following content

[
  {
    "name": "one"
  },
  {
    "name": "two-with-dashes"
  },
  {
    "name": "three with spaces"
  },
  {
    "name": "four_with_underscore"
  },
  {
    "name": "five+with%special#characters"
  }
]

Now when I try to use the where filter with each of those values via this liquid code:

{% assign one = site.data.test | where: "name", "one" %}
one: {{ one }}<br>
{% assign two = site.data.test | where: "name", "two-with-dashes" %}
two: {{ two }}<br>
{% assign three = site.data.test | where: "name", "three with spaces" %}
three: {{ three }}<br>
{% assign four = site.data.test | where: "name", "four_with_underscore" %}
four: {{ four }}<br>
{% assign five = site.data.test | where: "name", "five+with%special#characters" %}
five: {{ five }}

I get this output:

one: {"name"=>"one"}
two: {"name"=>"two-with-dashes"}
three: 
four: {"name"=>"four_with_underscore"}
five: {"name"=>"five+with%special#characters"}

Please note the key three with value three with spaces is not found by the where filter.

The Output I Wanted

one: {"name"=>"one"}
two: {"name"=>"two-with-dashes"}
three: {"name"=>"three with spaces"}
four: {"name"=>"four_with_underscore"}
five: {"name"=>"five+with%special#characters"}

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 21 (15 by maintainers)

Commits related to this issue

Most upvoted comments

It doesn’t, I’ll see if I can carve out time to figure fix it this week.

@timwis Nope! You did not screw up.

This only breaks when String.to_a is redefined, which you have no control over.

I was only trying to provide context, not blame 👍

According to git bisect, the commit that introduced this regression is 6245ddb14d0291ff7b581a937e804f871f792c30 which was introduced in #4555 by @timwis

I wasn’t offended, I always sound angry (even when I’m not, I’m weird) I was just pointing out what we try to do with Jekyll-Assets, though I will be looking into the issue because we don’t go anywhere near Jekyll’s filters, and we try to stay clear of Jekyll’s data to the point we 1.) Isolate and 2.) Copy and alter our own objects. We do add Jekyll#Configuration[“assets”] but that’s about it. We do utilize Jekyll’s filters for one of our internal plugins (to the point that we create a Liquid context with those filters inline) but we don’t go anywhere near Jekyll’s stuff.

I am absolutely intrigued as to how we could be triggering this, though based on the way I know my source works (unless there is a circumstance where I made a mistake – which is a possibility) we’ll probably end up back here as a Jekyll bug.