RFC - backslash escapes

From: Bill Moseley <moseley(at)not-real.hank.org>
Date: Mon Mar 18 2002 - 23:39:58 GMT
Hi,

This is an old topic, but this is regarding a change that, although
unlikely, could break existing swish-e configurations.

Currently the 2.1-dev version swish uses the backslash character to escape
the  character that follows the backslash, and is done in all cases.

What I'm not happy with is how this effects the entry of regular
expressions, so the change in consideration is for the backslash to only be
an escape character when used *within* quotes.

If anyone thinks this is a bad change, speak up!

Here's why I think it's a good idea:

At this time the backslash always escapes the next character when
processing so a regular expression to match the ".pdf" extension would need
to look like:

/\\.pdf$/ Swish converts the "\\" to a single backslash which is then passed onto the regular expression compiler. The problem with this is that if you forget the need for the double backslash and only use one in the swish config file, then you end up with the *valid* regular expression /.pdf$/ which
doesn't produce any errors, yet is not correct.

Also, if you want to match a real backslash (which I can't think of why
that would ever be done!) you would need an expression like
/path\\\\to\\\\dir/  which is painful to look at.

So, the proposal is to only enable backslash escaping when within quotes.
Thus these are all the same:

/\.pdf$/ "/\\.pdf$/"
'/\\.pdf\$/'

It's not very common to have single parameters that contain spaces, so
typically quotes are not needed for most swish parameters.

This change means these would not longer be the same:

"foo bar"
'foo bar'
foo\ bar

See any problems with this change?
--
Bill Moseley
mailto:moseley@hank.org

Received on Mon Mar 18 23:41:30 2002