weizhouapache commented on code in PR #7749:
URL: https://github.com/apache/cloudstack/pull/7749#discussion_r1270283007
##########
ui/src/utils/plugins.js:
##########
@@ -484,6 +484,22 @@ export const genericUtilPlugin = {
const regexExp =
/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/gi
return regexExp.test(uuid)
}
+
+ app.config.globalProperties.$toBase64Encoded = function (text) {
+ const base64regex =
/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/
+ if (base64regex.test(text)) {
+ return text
+ }
+ return btoa(unescape(encodeURIComponent(text)))
+ }
+
+ app.config.globalProperties.$toBase64AndURIEncoded = function (text) {
+ const base64regex =
/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/
+ if (base64regex.test(text)) {
Review Comment:
@shwstppr
if user input a base64-encoded string, it will be passed to cloudstack API
without encoding again, right ?
what if user wants to use the base64-encoded string as the userdata ?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]