1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Fixed Route Filter for link with special characters

Discussion in 'Resolved Bug Reports' started by xfrocks, Feb 18, 2014.

  1. xfrocks

    xfrocks Well-Known Member

    Configure Route Filter as below and it doesn't work.

    Screen Shot 2014-02-18 at 8.48.57 PM.png

    (I know, I know, the route is an add-on route but route filter should work with all kind of routes right?)

    I have track down the issues and problem lies in XenForo_Link::translateRouteFilterToRegex. This method does not perform urldecode for the target route ($to variable). I added this simple line before the return statement and everything works as expected.

    $to urldecode($to);
    Actually there are 2 approaches to fix this issue. The above is the first one. Another is to require admin to enter "tags/blah(space)blah(space)blah/" in "Find Route" and perform urlencode when build links. I prefer the first approach because it seems to use less server resources.
    Dinh Thanh likes this.
  2. Dinh Thanh

    Dinh Thanh Well-Known Member

    I confirm this bug.
  3. Mike

    Mike XenForo Developer Staff Member

    I'm not clear what the issue is. A simple test case calling XenForo_Link::buildPublicLink() directly would be preferred.

    If I do:
    echo XenForo_Link::buildPublicLink('tags/blah+blah/');
    The link is translated correctly.

    Now, if the URL being generated is actually "tags/blah blah/", I think that's an issue with the URL generation code you're using as it should be doing the necessary urlencode()'ing.

    I do see an issue with incoming conversions if your "replace with" has a "+" in it as they're urldecode()'d already.
    Last edited: Feb 19, 2014
  4. xfrocks

    xfrocks Well-Known Member

    Outgoing conversion works as expected with the above route filter:

    echo XenForo_Link::buildPublicLink('tags/blah+blah/');
    However, when user comes from blah/, the URL will be rewritten as tags/blah+blah/ which is incorrect.
    For incoming conversion, it should become tabs/blah(space)blah/.

    I hope it is clearer now.
  5. Mike

    Mike XenForo Developer Staff Member

    Right, that was roughly what I was getting at with the last line in my previous comment. The change has to be done "live" when handling the incoming route (or in the cache) as outgoing routes need to be URL encoded to be valid.

    The ideal would probably be to have the filtering done before URL decoding, but that's applies to a much bigger range of code. Doing the urldecode on the from/to on incoming route filters seems to work.
  6. xfrocks

    xfrocks Well-Known Member

    Totally agree. A simple urldecode should do the trick :)

Share This Page