garb icon indicating copy to clipboard operation
garb copied to clipboard

Filters with backslashes get double escaped

Open jrust opened this issue 13 years ago • 3 comments

Trying to create a filter like the following which needs to escape the question mark since it is a reserved character in regular expressions. Filter is: :page_path.contains => '^/search?'

The string that should be sent to Google Analytics is: filters=ga:pagePath%3D~%5E%2Fsearch%5C%3F

However, to_params escapes the backslash so that this is sent: filters=ga:pagePath%3D~%5E%2Fsearch%5C%5C%3F

Not sure why to_params escapes backslashes, but at least in this case it's making it impossible to escape the question mark.

jrust avatar Mar 09 '11 22:03 jrust

I did see on the filters API page that it says backslashes have to be escaped if you want to be able to search for a literal backslash. I would think, though, that the user creating the filter should escape a backslash so that the backslash can also be used to escape regexp characters.

jrust avatar Mar 09 '11 22:03 jrust

Yes, I think that makes sense. I'll have to revisit this when I work on the new filtering again.

tpitale avatar Sep 16 '11 00:09 tpitale

Encountered the same problem. +1

bogdan avatar Jul 25 '12 13:07 bogdan