garb
garb copied to clipboard
Filters with backslashes get double escaped
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.
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.
Yes, I think that makes sense. I'll have to revisit this when I work on the new filtering again.
Encountered the same problem. +1