Forum Discussion

mdcarson_58978's avatar
mdcarson_58978
Icon for Nimbostratus rankNimbostratus
Aug 14, 2012

Diacritics in iRules

(BIG-IP 11.1.0 Build 1943.0 Final)

 

 

I have URIs with accented characters for some international sites. I can forward a URI with diacritics by URL encoding the destination address.

 

 

But I don't seem to be able to match an encoded or decoded URL that originally contained accented characters in a switch statement, no matter what I try.

 

 

 

Forwarding to an encoded URL works:

 

when HTTP_REQUEST {

 

switch [string tolower [HTTP::uri]] {

 

 

/testme {

 

HTTP::respond 301 Location "http://mydomain.com/restauraci%C3%B3n"

 

}

 

}

 

 

 

Matching an encoded URI in a switch statement doesn't:

 

when HTTP_REQUEST {

 

switch [string tolower [HTTP::uri]] {

 

 

/restauraci%C3%B3n {

 

HTTP::respond 301 Location "http://mydomain.com/newlocation"

 

}

 

}

 

 

 

 

Browsing to http://mydomain.com/restauración (http://mydomain.com/restauraci%C3%B3n) doesn't get forwarded.

 

 

 

 

 

I did a test to see what the decoded URI looks like:

 

when HTTP_REQUEST {

 

switch [URI::decode [string tolower [HTTP::uri]]] {

 

 

/restauraci* {

 

200 content "[URI::decode [HTTP::uri]]"

 

}

 

}

 

 

 

 

Browsing to http://mydomain.com/restauración I get "/restauración"

 

Using the same rule without the decode, I get "/restauraci%C3%B3n"

 

 

 

Trying to match the decoded URI (or anything else) doesn't work either:

 

when HTTP_REQUEST {

 

switch [URI::decode [string tolower [HTTP::uri]]] {

 

 

/restauración -

 

/restauraci%C3%B3n -

 

/restauración {

 

HTTP::respond 301 Location "http://mydomain.com/newlocation"

 

}

 

}

 

 

 

 

Is there a simple way to filter on an encoded URI?

 

 

  • If the URI is encoded properly by the browser, this should work as long as you set the cases to lower case:

    
    when HTTP_REQUEST { 
    switch [string tolower [HTTP::uri]] {
      /restauraci%c3%b3n {
        HTTP::respond 301 Location "http://mydomain.com/newlocation"
      }
    }
    

    Aaron
  • I skipped the string tolower in my simplified examples, but we actually have it in the iRule.

     

    switch -glob [string tolower [HTTP::uri]] {

     

     

    I don't think it's a browser encoding issue, because I get the same results in Chrome, FF, IE, etc.
  • Can you log the value from the browser?

    
    when HTTP_REQUEST {
     switch [string tolower [HTTP::uri]] {
      /restauraci%c3%b3n {
        log local0. "matched: /restauraci%c3%b3n"
        HTTP::respond 301 Location "http://mydomain.com/newlocation"
      }
      default {
        log local0. "no match: [string tolower [HTTP::uri]]"
      }
    }
    

    Aaron