danielaparker / jsoncons

A C++, header-only library for constructing JSON and JSON-like data formats, with JSON Pointer, JSON Patch, JSON Schema, JSONPath, JMESPath, CSV, MessagePack, CBOR, BSON, UBJSON
https://danielaparker.github.io/jsoncons
Other
697 stars 160 forks source link

endless loop in jmespath::search #469

Closed MonkeybreadSoftware closed 9 months ago

MonkeybreadSoftware commented 9 months ago

if the expression for jmespath::search contains an extra CR on the end, we get an endless loop.

It looks like advance_past_space_character detects we are >= end and thus sets ec to an error. But ec is not checked.

So after calling advance_past_space_character(ec);, we may need to add if (ec) {return jmespath_expression();} to exit the loop.

danielaparker commented 9 months ago

Interesting edge case, I changed advance_past_space_character to allow it, since we already allow a CR followed by a space character (on master.)