File tree Expand file tree Collapse file tree 2 files changed +16
-1
lines changed
main/java/com/alibaba/dubbo/common
test/java/com/alibaba/dubbo/common Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -224,7 +224,7 @@ public static URL valueOf(String url) {
224224 path = url .substring (i + 1 );
225225 url = url .substring (0 , i );
226226 }
227- i = url .indexOf ("@" );
227+ i = url .lastIndexOf ("@" );
228228 if (i >= 0 ) {
229229 username = url .substring (0 , i );
230230 int j = username .indexOf (":" );
Original file line number Diff line number Diff line change @@ -637,4 +637,19 @@ public void testAddParameters() throws Exception {
637637 parameters .put ("version" , null );
638638 url .addParameters (parameters );
639639 }
640+
641+ @ Test
642+ public void testUserNamePasswordContainsAt (){
643+ // Test username or password contains "@"
644+ URL url = URL .valueOf ("ad@min:hello@1234@10.20.130.230:20880/context/path?version=1.0.0&application=morgan" );
645+ assertNull (url .getProtocol ());
646+ assertEquals ("ad@min" , url .getUsername ());
647+ assertEquals ("hello@1234" , url .getPassword ());
648+ assertEquals ("10.20.130.230" , url .getHost ());
649+ assertEquals (20880 , url .getPort ());
650+ assertEquals ("context/path" , url .getPath ());
651+ assertEquals (2 , url .getParameters ().size ());
652+ assertEquals ("1.0.0" , url .getParameter ("version" ));
653+ assertEquals ("morgan" , url .getParameter ("application" ));
654+ }
640655}
You can’t perform that action at this time.
0 commit comments