You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by ki...@apache.org on 2024/01/12 18:38:58 UTC

(dubbo) branch 3.2 updated: Revert "Fix URL parse pwd failed when the pwd contains '#'" (#13645)

This is an automated email from the ASF dual-hosted git repository.

kimmking pushed a commit to branch 3.2
in repository https://gitbox.apache.org/repos/asf/dubbo.git


The following commit(s) were added to refs/heads/3.2 by this push:
     new 16cdc5290e Revert "Fix URL parse pwd failed when the pwd contains '#'" (#13645)
16cdc5290e is described below

commit 16cdc5290e65af9db528470f7f7f51657dd61939
Author: kimmking <ki...@gmail.com>
AuthorDate: Sat Jan 13 02:38:51 2024 +0800

    Revert "Fix URL parse pwd failed when the pwd contains '#'" (#13645)
---
 .../java/org/apache/dubbo/common/URLStrParser.java  | 21 ++++-----------------
 .../org/apache/dubbo/common/URLStrParserTest.java   |  1 -
 2 files changed, 4 insertions(+), 18 deletions(-)

diff --git a/dubbo-common/src/main/java/org/apache/dubbo/common/URLStrParser.java b/dubbo-common/src/main/java/org/apache/dubbo/common/URLStrParser.java
index c8ee6337e4..3b1761e2ff 100644
--- a/dubbo-common/src/main/java/org/apache/dubbo/common/URLStrParser.java
+++ b/dubbo-common/src/main/java/org/apache/dubbo/common/URLStrParser.java
@@ -18,15 +18,12 @@ package org.apache.dubbo.common;
 
 import org.apache.dubbo.common.url.component.ServiceConfigURL;
 import org.apache.dubbo.common.url.component.URLItemCache;
-import org.apache.dubbo.common.utils.StringUtils;
 
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
 
 import static org.apache.dubbo.common.constants.CommonConstants.DEFAULT_KEY_PREFIX;
-import static org.apache.dubbo.common.constants.CommonConstants.PASSWORD_KEY;
-import static org.apache.dubbo.common.constants.CommonConstants.USERNAME_KEY;
 import static org.apache.dubbo.common.utils.StringUtils.EMPTY_STRING;
 import static org.apache.dubbo.common.utils.StringUtils.decodeHexByte;
 import static org.apache.dubbo.common.utils.Utf8Utils.decodeUtf8;
@@ -45,8 +42,8 @@ public final class URLStrParser {
     }
 
     /**
-     * @param decodedURLStr : after {@link URL#decode} string decodedURLStr format:
-     *                      protocol://username:password@host:port/path?k1=v1&k2=v2
+     * @param decodedURLStr : after {@link URL#decode} string
+     *                      decodedURLStr format: protocol://username:password@host:port/path?k1=v1&k2=v2
      *                      [protocol://][username:password@][host:port]/[path][?k1=v1&k2=v2]
      */
     public static URL parseDecodedStr(String decodedURLStr) {
@@ -106,7 +103,6 @@ public final class URLStrParser {
         int starIdx = 0, endIdx = decodedBody.length();
         // ignore the url content following '#'
         int poundIndex = decodedBody.indexOf('#');
-
         if (poundIndex != -1) {
             endIdx = poundIndex;
         }
@@ -151,15 +147,6 @@ public final class URLStrParser {
             }
             starIdx = pwdEndIdx + 1;
         }
-        if (username == null && parameters != null && StringUtils.isNotEmpty(parameters.get(USERNAME_KEY))) {
-            username = parameters.get(USERNAME_KEY);
-            parameters.remove(USERNAME_KEY);
-        }
-
-        if (password == null && parameters != null && StringUtils.isNotEmpty(parameters.get(PASSWORD_KEY))) {
-            password = parameters.get(PASSWORD_KEY);
-            parameters.remove(PASSWORD_KEY);
-        }
 
         String host = null;
         int port = 0;
@@ -216,8 +203,8 @@ public final class URLStrParser {
     }
 
     /**
-     * @param encodedURLStr : after {@link URL#encode(String)} string encodedURLStr after decode format:
-     *                      protocol://username:password@host:port/path?k1=v1&k2=v2
+     * @param encodedURLStr : after {@link URL#encode(String)} string
+     *                      encodedURLStr after decode format: protocol://username:password@host:port/path?k1=v1&k2=v2
      *                      [protocol://][username:password@][host:port]/[path][?k1=v1&k2=v2]
      */
     public static URL parseEncodedStr(String encodedURLStr) {
diff --git a/dubbo-common/src/test/java/org/apache/dubbo/common/URLStrParserTest.java b/dubbo-common/src/test/java/org/apache/dubbo/common/URLStrParserTest.java
index 01364faab9..4c4c218c35 100644
--- a/dubbo-common/src/test/java/org/apache/dubbo/common/URLStrParserTest.java
+++ b/dubbo-common/src/test/java/org/apache/dubbo/common/URLStrParserTest.java
@@ -48,7 +48,6 @@ class URLStrParserTest {
         testCases.add("nacos://192.168.1.1:8848?username=&password=");
         testCases.add("dubbo://127.0.0.1?timeout=1234&default.timeout=5678");
         testCases.add("dubbo://127.0.0.1?default.timeout=5678");
-        testCases.add("zookeeper://test10.301.216.302:2181?username=t1#&password=t2#");
 
         errorDecodedCases.add("dubbo:192.168.1.1");
         errorDecodedCases.add("://192.168.1.1");