Matching of special characters in location

Francis Daly francis at daoine.org
Wed Nov 11 00:34:07 UTC 2020


On Tue, Nov 10, 2020 at 02:54:26AM +0100, Grzegorz Kulewski wrote:
> W dniu 10.11.2020 o 01:19, Francis Daly pisze:

Hi there,

> > So my config file can include (e.g.)
> > 
> >   location ^~/<200b> { return 200 "match /zwsp ($uri, $request_uri)\n"; }
> > 
> > (except there is only one "character" between the / and the space);
> > and then any request that starts with /%e2%80%8b should be handled in
> > that location; and any request that does not, should not be.
> 
> Including raw UTF-8 special characters in nginx config isn't my ideal sane solution. :)

That's reasonable; but I think I'd disagree.

I'd suggest that if you can't write the character, you probably shouldn't
be using it in your web site such that it is needed in this part of the
config file :-)

> I think I would prefer to be able to use escapes in non-regexp matches too...

That's a reasonable preference. Current stock-nginx does not support it,
as far as I know. But you can add it yourself, if it is important enough.

If you can decide on an escape syntax that you like (and: most will
probably break some current valid config, so you'll want to choose one
that works for you), then you can either try to get the code to handle
it added to nginx; or (more likely, in the short term at least) you can
write a pre-processor for you that turns your nginx.conf.in (with escaped
characters in "location" values that start with something other than ~
or @) into an nginx.conf that includes the un-escaped characters in the
format that current-nginx will read.

Cheers,

	f
-- 
Francis Daly        francis at daoine.org


More information about the nginx mailing list