MongoURI parsing does not handle escaping

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Cannot Reproduce
    • Priority: Major - P3
    • None
    • Affects Version/s: 2.6.5
    • Component/s: API
    • None
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      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

            Assignee:
            Unassigned
            Reporter:
            Caleb Jones
            None
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: