Uploaded image for project: 'Java Driver'
  1. Java Driver
  2. JAVA-449

MongoURI parsing does not handle escaping

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Icon: Major - P3 Major - P3
    • None
    • 2.6.5
    • API
    • None

    Description

      Repro steps:

      JUnit Test Snippet

      @Test
      public void testMultipleAts() {
         MongoURI uri = new MongoURI("mongodb://usernme:p@ssword@localhost:27017/test");
         assertEquals("p@ssword", uri.getPassword()); // <-- FAILS
       
         // this behavior might be expected behavior as '@' should be URI-escaped
         // however maybe a parse error should be thrown since at this point:
         //   * uri.getHosts() == ["ssword@localhost:27017"]
         //   * uri.getPassword() == ['p']
      }
       
      @Test
      public void testUriEscaping() {
         MongoURI uri = new MongoURI("mongodb://usernme:p%40ssword@localhost:27017/test");
         assertEquals("p@ssword", uri.getPassword()); // <-- FAILS and shouldn't
       
         // at this point uri.getPassword() == ['p', '%', '4', '0', 's', 's', 'w', 'o', 'r', 'd']
         // which is wrong
      }

      Expected:

      • MongoURI should support URI escaping.

      Actual:

      • No URI escaping/unescaping is handled in MongoURI

      Attachments

        Activity

          People

            Unassigned Unassigned
            calebjones Caleb Jones
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: