Re: [PATCH v1 3/5] list-objects-filter: implement composite filters
- From
Matthew DeVore <matvore@comcast.net>
- Date
- Jun 4, 2019, 17:19 UTC
- Message-ID
- <20190604171952.GI4641@comcast.net>
- In-Reply-To
- <20190604161332.GA29603@sigill.intra.peff.net>
On Tue, Jun 04, 2019 at 12:13:32PM -0400, Jeff King wrote:
Show 7 quoted lines
> > - return has_reserved_character(subspec, errbuf) || > > - url_decode(subspec, errbuf) || > > - gently_parse_list_objects_filter( > > - &filter_options->sub[new_index], subspec->buf, errbuf); > > + decoded = url_percent_decode(subspec->buf); > > I think you can get rid of has_reserved_character() now, too.
The purpose of has_reserved_character is to allow for future extensibility if someone decides to implement a more sophisticated DSL and give meaning to these characters. That may be a long-shot, but it seems worth it.
> The reserved character list is still used on the encoding side. But I > think you could switch to strbuf_add_urlencode() there?
strbuf_addstr_urlencode will either escape or not escape all rfc3986 reserved characters, and that set includes both : and +. The former should not require escaping since it's a common character in filter specs, and I would like the hand-encoded combine specs to be relatively easy to type and read. The + must be escaped since it is used as part of the combine:... syntax to delimit sub filters. So strbuf_addstr_url_encode would have to be more customizable to make it work for this context. I'd like to add a parameterizable should_escape predicate (iow function pointer) which strbuf_addstr_urlencode accepts. I actually think this will be more readable than the current strbuf API.