Skip to content

Commit b1e2e9a

Browse files
committed
<fix>[expon]: decode url if complex password
Resolves: ZSTAC-65479 Change-Id: I6b7876626c686f787362646e73636570666e6d63
1 parent 2ba625d commit b1e2e9a

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

plugin/expon/src/main/java/org/zstack/expon/ExponStorageController.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,9 @@
5252
import org.zstack.utils.path.PathUtil;
5353
import org.zstack.vhost.kvm.VhostVolumeTO;
5454

55+
import java.io.UnsupportedEncodingException;
5556
import java.net.URI;
57+
import java.net.URLDecoder;
5658
import java.util.*;
5759
import java.util.concurrent.TimeUnit;
5860
import java.util.stream.Collectors;
@@ -122,7 +124,11 @@ public ExponStorageController(String url) {
122124

123125
AccountInfo accountInfo = new AccountInfo();
124126
accountInfo.username = uri.getUserInfo().split(":")[0];
125-
accountInfo.password = uri.getUserInfo().split(":")[1];
127+
try {
128+
accountInfo.password = URLDecoder.decode(uri.getUserInfo().split(":")[1], "utf-8");
129+
} catch (UnsupportedEncodingException e) {
130+
throw new RuntimeException(e);
131+
}
126132

127133
apiHelper = new ExponApiHelper(accountInfo, client);
128134
}

test/src/test/groovy/org/zstack/test/integration/storage/primary/addon/ExternalPrimaryStorageCase.groovy

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ class ExternalPrimaryStorageCase extends SubCase {
187187
KVMGlobalConfig.VM_SYNC_ON_HOST_PING.updateValue(true)
188188
simulatorEnv()
189189
testCreateExponStorage()
190+
testComplexPassword()
190191
testSessionExpired()
191192
testCreateVm()
192193
testHandleInactiveVolume()
@@ -299,6 +300,15 @@ class ExternalPrimaryStorageCase extends SubCase {
299300
}
300301
}
301302

303+
void testComplexPassword() {
304+
String pswd = "Pswd@#123"
305+
String encodePswd = URLEncoder.encode(pswd, "UTF-8")
306+
discoverExternalPrimaryStorage {
307+
url = String.format("https://complex:%[email protected]:443/pool", encodePswd)
308+
identity = "expon"
309+
}
310+
}
311+
302312
void testSessionExpired() {
303313
controller.apiHelper.sessionId = "invalid"
304314
}

0 commit comments

Comments
 (0)