Uploaded image for project: 'Apache Knox'
  1. Apache Knox
  2. KNOX-690

URL Template matching not properly handling encoded URLs

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 0.9.0
    • 0.9.0
    • Server
    • None

    Description

      For example as shown below the literal "test-scheme://test-host:42/%7C" does not match the template "://:*/|" as it probably should. The test below can be added to knox-url-decode/gateway-util-urltemplate/src/test/java/org/apache/hadoop/gateway/util/urltemplate/MatcherTest.java to help work on the issue.

        @Test
        public void testEncodedUrlMatching() throws Exception {
          Template template;
          Template input;
          Matcher<String> matcher;
          Matcher<?>.Match match;
      
          matcher = new Matcher<String>();
      
          template = Parser.parseTemplate( "*://*:*/example" );
          matcher.add( template, "test-example" );
      
          template = Parser.parseTemplate( "*://*:*/|" );
          matcher.add( template, "test-pipe-in-path" );
      
          template = Parser.parseTemplate( "*://*:*/test-path?{|=*}" );
          matcher.add( template, "test-pipe-in-query-param-name" );
      
          template = Parser.parseTemplate( "*://*:*/test-path?{test-param-name=*}" );
          matcher.add( template, "test-pipe-in-query-param-value" );
      
          template = Parser.parseTemplate( "*://*:*/path#|" );
          matcher.add( template, "test-pipe-in-fragment" );
      
          input = Parser.parseLiteral( "test-scheme://test-host:42/example" );
          match = matcher.match( input );
          assertThat( match, notNullValue() );
          assertThat( (String)match.getValue(), is( "test-example" ) );
      
          input = Parser.parseLiteral( "test-scheme://test-host:42/%7C" );
          match = matcher.match( input );
          assertThat( match, notNullValue() );
          assertThat( (String)match.getValue(), is( "test-pipe-in-path" ) );
      
          input = Parser.parseLiteral( "test-scheme://test-host:42/test-path?%7C=test-param-value" );
          match = matcher.match( input );
          assertThat( match, notNullValue() );
          assertThat( (String)match.getValue(), is( "test-pipe-in-query-param-name" ) );
      
          input = Parser.parseLiteral( "test-scheme://test-host:42/test-path?test-param-name=%7C" );
          match = matcher.match( input );
          assertThat( match, notNullValue() );
          assertThat( (String)match.getValue(), is( "test-pipe-in-query-param-value" ) );
      
          input = Parser.parseLiteral( "test-scheme://test-host:42/test-path#%7C" );
          match = matcher.match( input );
          assertThat( match, notNullValue() );
          assertThat( (String)match.getValue(), is( "test-pipe-in-fragment" ) );
        }
      

      Attachments

        Issue Links

          Activity

            People

              sumit.gupta Sumit Gupta
              kminder Kevin Minder
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: