This is an automated email from the ASF dual-hosted git repository.
pearl11594 pushed a commit to branch 4.20
in repository https://gitbox.apache.org/repos/asf/cloudstack.git
The following commit(s) were added to refs/heads/4.20 by this push:
new 0e0ae226bd2 Xenserver smoke-test: Allow emojis to be accepted in
volume name during volume creation (#10774)
0e0ae226bd2 is described below
commit 0e0ae226bd2f7eddcb19f5248693e065da078105
Author: Pearl Dsilva <[email protected]>
AuthorDate: Tue Apr 29 11:43:07 2025 +0530
Xenserver smoke-test: Allow emojis to be accepted in volume name during
volume creation (#10774)
* Allow emojis to be accepted in volume name during volume creation
* escape only non-ASCII characters
---
.../resource/XenServerStorageProcessor.java | 23 +++++++++++++++++++++-
1 file changed, 22 insertions(+), 1 deletion(-)
diff --git
a/plugins/hypervisors/xenserver/src/main/java/com/cloud/hypervisor/xenserver/resource/XenServerStorageProcessor.java
b/plugins/hypervisors/xenserver/src/main/java/com/cloud/hypervisor/xenserver/resource/XenServerStorageProcessor.java
index 4298c9a7218..1d405316ad7 100644
---
a/plugins/hypervisors/xenserver/src/main/java/com/cloud/hypervisor/xenserver/resource/XenServerStorageProcessor.java
+++
b/plugins/hypervisors/xenserver/src/main/java/com/cloud/hypervisor/xenserver/resource/XenServerStorageProcessor.java
@@ -23,6 +23,7 @@ import static com.cloud.utils.ReflectUtil.flattenProperties;
import static com.google.common.collect.Lists.newArrayList;
import java.io.File;
+import java.io.UnsupportedEncodingException;
import java.net.URI;
import java.util.ArrayList;
import java.util.Arrays;
@@ -810,7 +811,7 @@ public class XenServerStorageProcessor implements
StorageProcessor {
final SR poolSr = hypervisorResource.getStorageRepository(conn,
CitrixHelper.getSRNameLabel(primaryStore.getUuid(),
primaryStore.getPoolType(), primaryStore.getPath()));
VDI.Record vdir = new VDI.Record();
- vdir.nameLabel = volume.getName();
+ vdir.nameLabel = getEncodedVolumeName(volume.getName());
vdir.SR = poolSr;
vdir.type = Types.VdiType.USER;
@@ -831,6 +832,26 @@ public class XenServerStorageProcessor implements
StorageProcessor {
}
}
+ private String getEncodedVolumeName(String volumeName) throws
UnsupportedEncodingException {
+ byte[] utf8Bytes = volumeName.getBytes("UTF-8");
+ // Decode UTF-8 into a Java String (UTF-16)
+ String decoded = new String(utf8Bytes, "UTF-8");
+ // Print each code unit as a Unicode escape
+ StringBuilder unicodeEscaped = new StringBuilder();
+ for (int i = 0; i < decoded.length(); i++) {
+ char ch = decoded.charAt(i);
+ if (ch <= 127 && Character.isLetterOrDigit(ch)) {
+ // Keep ASCII alphanumerics as-is
+ unicodeEscaped.append(ch);
+ } else {
+ // Escape non-ASCII characters
+ unicodeEscaped.append(String.format("\\u%04X", (int) ch));
+ }
+ }
+
+ return unicodeEscaped.toString();
+ }
+
@Override
public Answer cloneVolumeFromBaseTemplate(final CopyCommand cmd) {
final Connection conn = hypervisorResource.getConnection();