This is an automated email from the ASF dual-hosted git repository. kimmking pushed a commit to branch revert-13631-feat/fix_url_parse in repository https://gitbox.apache.org/repos/asf/dubbo.git
commit f33476f4f09eb707c0aef192fc5c653fafa69394 Author: kimmking <[email protected]> AuthorDate: Sat Jan 13 02:38:05 2024 +0800 Revert "Fix URL parse pwd failed when the pwd contains '#'" --- .../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");
