You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by "shwstppr (via GitHub)" <gi...@apache.org> on 2023/07/18 09:56:59 UTC
[GitHub] [cloudstack] shwstppr opened a new pull request, #7749: ui: fix userdata base64 encoding
shwstppr opened a new pull request, #7749:
URL: https://github.com/apache/cloudstack/pull/7749
### Description
Fixes #7748
### Types of changes
- [ ] Breaking change (fix or feature that would cause existing functionality to change)
- [ ] New feature (non-breaking change which adds functionality)
- [x] Bug fix (non-breaking change which fixes an issue)
- [ ] Enhancement (improves an existing feature and functionality)
- [ ] Cleanup (Code refactoring and cleanup, that may add test cases)
### Feature/Enhancement Scale or Bug Severity
#### Feature/Enhancement Scale
- [ ] Major
- [ ] Minor
#### Bug Severity
- [ ] BLOCKER
- [ ] Critical
- [ ] Major
- [ ] Minor
- [ ] Trivial
### Screenshots (if appropriate):
### How Has This Been Tested?
<!-- Please describe in detail how you tested your changes. -->
<!-- Include details of your testing environment, and the tests you ran to -->
<!-- see how your change affects other areas of the code, etc. -->
<!-- Please read the [CONTRIBUTING](https://github.com/apache/cloudstack/blob/main/CONTRIBUTING.md) document -->
--
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: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [cloudstack] shwstppr commented on pull request #7749: ui: fix userdata base64 encoding
Posted by "shwstppr (via GitHub)" <gi...@apache.org>.
shwstppr commented on PR #7749:
URL: https://github.com/apache/cloudstack/pull/7749#issuecomment-1645050565
@blueorangutan ui
--
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: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [cloudstack] blueorangutan commented on pull request #7749: ui: fix userdata base64 encoding
Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #7749:
URL: https://github.com/apache/cloudstack/pull/7749#issuecomment-1645051539
@shwstppr a Jenkins job has been kicked to build UI QA env. I'll keep you posted as I make progress.
--
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: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [cloudstack] blueorangutan commented on pull request #7749: ui: fix userdata base64 encoding
Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #7749:
URL: https://github.com/apache/cloudstack/pull/7749#issuecomment-1639913480
@shwstppr a Jenkins job has been kicked to build UI QA env. I'll keep you posted as I make progress.
--
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: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [cloudstack] weizhouapache commented on a diff in pull request #7749: ui: fix userdata base64 encoding
Posted by "weizhouapache (via GitHub)" <gi...@apache.org>.
weizhouapache commented on code in PR #7749:
URL: https://github.com/apache/cloudstack/pull/7749#discussion_r1270528099
##########
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:
> @weizhouapache why would user want to pass a double base64 encoded string? cloud-init doesn't have a data format for that, https://cloudinit.readthedocs.io/en/latest/explanation/format.html Even if user wants that in some scenarios it can be done manually.
@shwstppr
cloud-init is a way to use userdata, but not the only one.
maybe we can add a checkbox to indicate if the input is base64-encoded or not. we can do it later.
--
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: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [cloudstack] weizhouapache commented on pull request #7749: ui: fix userdata base64 encoding
Posted by "weizhouapache (via GitHub)" <gi...@apache.org>.
weizhouapache commented on PR #7749:
URL: https://github.com/apache/cloudstack/pull/7749#issuecomment-1645372718
code lgtm
tested ok
--
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: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [cloudstack] shwstppr commented on pull request #7749: ui: fix userdata base64 encoding
Posted by "shwstppr (via GitHub)" <gi...@apache.org>.
shwstppr commented on PR #7749:
URL: https://github.com/apache/cloudstack/pull/7749#issuecomment-1643511282
@blueorangutan ui
--
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: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [cloudstack] codecov[bot] commented on pull request #7749: ui: fix userdata base64 encoding
Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #7749:
URL: https://github.com/apache/cloudstack/pull/7749#issuecomment-1640019256
## [Codecov](https://app.codecov.io/gh/apache/cloudstack/pull/7749?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
> Merging [#7749](https://app.codecov.io/gh/apache/cloudstack/pull/7749?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) (799ff55) into [4.18](https://app.codecov.io/gh/apache/cloudstack/commit/d575cae3e3f2834b6e548557e914f795d866c30a?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) (d575cae) will **decrease** coverage by `0.01%`.
> The diff coverage is `n/a`.
```diff
@@ Coverage Diff @@
## 4.18 #7749 +/- ##
============================================
- Coverage 13.02% 13.02% -0.01%
+ Complexity 9028 9027 -1
============================================
Files 2719 2719
Lines 256868 256868
Branches 40051 40051
============================================
- Hits 33449 33447 -2
- Misses 219231 219234 +3
+ Partials 4188 4187 -1
```
[see 1 file with indirect coverage changes](https://app.codecov.io/gh/apache/cloudstack/pull/7749/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
:mega: We’re building smart automated test selection to slash your CI/CD build times. [Learn more](https://about.codecov.io/iterative-testing/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
--
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: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [cloudstack] blueorangutan commented on pull request #7749: ui: fix userdata base64 encoding
Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #7749:
URL: https://github.com/apache/cloudstack/pull/7749#issuecomment-1645061923
UI build: :heavy_check_mark:
Live QA URL: https://qa.cloudstack.cloud/simulator/pr/7749 (QA-JID-128)
--
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: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [cloudstack] weizhouapache commented on a diff in pull request #7749: ui: fix userdata base64 encoding
Posted by "weizhouapache (via GitHub)" <gi...@apache.org>.
weizhouapache commented on code in PR #7749:
URL: https://github.com/apache/cloudstack/pull/7749#discussion_r1269210885
##########
ui/src/utils/plugins.js:
##########
@@ -484,6 +484,14 @@ 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
Review Comment:
@shwstppr
I will verify it
--
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: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [cloudstack] weizhouapache commented on a diff in pull request #7749: ui: fix userdata base64 encoding
Posted by "weizhouapache (via GitHub)" <gi...@apache.org>.
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: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [cloudstack] shwstppr commented on a diff in pull request #7749: ui: fix userdata base64 encoding
Posted by "shwstppr (via GitHub)" <gi...@apache.org>.
shwstppr commented on code in PR #7749:
URL: https://github.com/apache/cloudstack/pull/7749#discussion_r1270273890
##########
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) {
Review Comment:
moved everything in a single method
--
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: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [cloudstack] weizhouapache merged pull request #7749: ui: fix userdata base64 encoding
Posted by "weizhouapache (via GitHub)" <gi...@apache.org>.
weizhouapache merged PR #7749:
URL: https://github.com/apache/cloudstack/pull/7749
--
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: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [cloudstack] shwstppr commented on pull request #7749: ui: fix userdata base64 encoding
Posted by "shwstppr (via GitHub)" <gi...@apache.org>.
shwstppr commented on PR #7749:
URL: https://github.com/apache/cloudstack/pull/7749#issuecomment-1639912821
@blueorangutan ui
--
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: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [cloudstack] blueorangutan commented on pull request #7749: ui: fix userdata base64 encoding
Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #7749:
URL: https://github.com/apache/cloudstack/pull/7749#issuecomment-1643512420
@shwstppr a Jenkins job has been kicked to build UI QA env. I'll keep you posted as I make progress.
--
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: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [cloudstack] shwstppr commented on a diff in pull request #7749: ui: fix userdata base64 encoding
Posted by "shwstppr (via GitHub)" <gi...@apache.org>.
shwstppr commented on code in PR #7749:
URL: https://github.com/apache/cloudstack/pull/7749#discussion_r1270273527
##########
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:
This can be useful when user enters an already base64 encoded string.
Use-case: cloud-init allows passing gzipped content. To pass it ACS API user will already have a base64 encoded string created with means like, https://base64.guru/converter/encode/file
--
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: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [cloudstack] blueorangutan commented on pull request #7749: ui: fix userdata base64 encoding
Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #7749:
URL: https://github.com/apache/cloudstack/pull/7749#issuecomment-1639933345
UI build: :heavy_check_mark:
Live QA URL: https://qa.cloudstack.cloud/simulator/pr/7749 (QA-JID-125)
--
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: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [cloudstack] shwstppr commented on a diff in pull request #7749: ui: fix userdata base64 encoding
Posted by "shwstppr (via GitHub)" <gi...@apache.org>.
shwstppr commented on code in PR #7749:
URL: https://github.com/apache/cloudstack/pull/7749#discussion_r1270288795
##########
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:
@weizhouapache why would user want to pass a double base64 encoded string?
cloud-init doesn't have a data format for that, https://cloudinit.readthedocs.io/en/latest/explanation/format.html
Even if user wants that in some scenarios it can be done manually.
--
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: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [cloudstack] weizhouapache commented on a diff in pull request #7749: ui: fix userdata base64 encoding
Posted by "weizhouapache (via GitHub)" <gi...@apache.org>.
weizhouapache commented on code in PR #7749:
URL: https://github.com/apache/cloudstack/pull/7749#discussion_r1269037521
##########
ui/src/utils/plugins.js:
##########
@@ -484,6 +484,14 @@ 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
Review Comment:
@shwstppr
why not return `encodeURIComponent(text)` here ?
--
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: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [cloudstack] shwstppr commented on a diff in pull request #7749: ui: fix userdata base64 encoding
Posted by "shwstppr (via GitHub)" <gi...@apache.org>.
shwstppr commented on code in PR #7749:
URL: https://github.com/apache/cloudstack/pull/7749#discussion_r1269133770
##########
ui/src/utils/plugins.js:
##########
@@ -484,6 +484,14 @@ 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
Review Comment:
@weizhouapache refactored
--
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: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [cloudstack] weizhouapache commented on a diff in pull request #7749: ui: fix userdata base64 encoding
Posted by "weizhouapache (via GitHub)" <gi...@apache.org>.
weizhouapache commented on code in PR #7749:
URL: https://github.com/apache/cloudstack/pull/7749#discussion_r1269270613
##########
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:
do we need this check ?
##########
ui/src/utils/plugins.js:
##########
@@ -484,6 +484,14 @@ 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
Review Comment:
tested ok. I have some other comments
##########
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) {
Review Comment:
@shwstppr
this looks same as toBase64Encoded ?
--
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: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org