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

Json parser gets tripped up on curly brace in property value #2964

Closed
springmeyer opened this issue Jul 10, 2015 · 4 comments
Closed

Json parser gets tripped up on curly brace in property value #2964

springmeyer opened this issue Jul 10, 2015 · 4 comments
Milestone

Comments

@springmeyer
Copy link
Member

This valid json fails to parse (when cache_features:False):

{
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "properties": {
        "curly1": "}"
      },
      "geometry": {
        "type": "Point",
        "coordinates": [ -122,48 ]
      }
    }
  ]
}

So does this fail to parse:

{
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "properties": {
        "curly1": "{"
      },
      "geometry": {
        "type": "Point",
        "coordinates": [ -122,48 ]
      }
    }
  ]
}

However, curiously, this does parse:

{
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "properties": {
        "curly1": "}",
        "curly2": "{"
      },
      "geometry": {
        "type": "Point",
        "coordinates": [ -122,48 ]
      }
    }
  ]
}
@springmeyer springmeyer added this to the Mapnik 3.1.0 milestone Jul 10, 2015
@artemp
Copy link
Member

artemp commented Jul 10, 2015

@springmeyer - yep, bug, working on fix.

Background : curly brackets are used to determine feature boundary in GeoJSON when 'cache-features="false"(extract_bounding_box grammar). Currently we process every{ }` even if they are a part of a quoted string:

feature = raw[lit('{')[_a = 1]
                  >> *(eps(_a > 0) >> (lit('{')[_a += 1]
                                       |
                                       lit('}')[_a -=1]
                                       |
                                       coords[_b = _1]                                      
                                       |
                                       char_))][push_box(_r1, _r2, _b, _1)]

@artemp
Copy link
Member

artemp commented Jul 10, 2015

@springmeyer - this is now fixed in 6325bf2

@springmeyer
Copy link
Member Author

✔️ - confirmed fix locally. Want to add regression test before closing?

@springmeyer
Copy link
Member Author

tests added in 16e6db3, and fixed up (to actually test both modes of cache_features in b54b275

springmeyer pushed a commit that referenced this issue Jul 10, 2015
@springmeyer springmeyer modified the milestones: Mapnik 3.0.1, Mapnik 3.1.0 Jul 16, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants