File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11661166"label.ipv6.subnets" : " IPv6 Subnets" ,
11671167"label.ip.addresses" : " IP Addresses" ,
11681168"label.iqn" : " Target IQN" ,
1169+ "label.is.base64.encoded" : " Base64 encoded" ,
11691170"label.is.in.progress" : " is in progress" ,
11701171"label.is.shared" : " Is shared" ,
11711172"label.is2faenabled" : " Is 2FA enabled" ,
Original file line number Diff line number Diff line change @@ -492,6 +492,15 @@ export const fileSizeUtilPlugin = {
492492 }
493493}
494494
495+ function isBase64 ( str ) {
496+ try {
497+ const decoded = new TextDecoder ( ) . decode ( Uint8Array . from ( atob ( str ) , c => c . charCodeAt ( 0 ) ) )
498+ return btoa ( decoded ) === str
499+ } catch ( err ) {
500+ return false
501+ }
502+ }
503+
495504export const genericUtilPlugin = {
496505 install ( app ) {
497506 app . config . globalProperties . $isValidUuid = function ( uuid ) {
@@ -500,8 +509,7 @@ export const genericUtilPlugin = {
500509 }
501510
502511 app . config . globalProperties . $toBase64AndURIEncoded = function ( text ) {
503- const base64regex = / ^ ( [ 0 - 9 a - z A - Z + / ] { 4 } ) * ( ( [ 0 - 9 a - z A - Z + / ] { 2 } = = ) | ( [ 0 - 9 a - z A - Z + / ] { 3 } = ) ) ? $ /
504- if ( base64regex . test ( text ) ) {
512+ if ( isBase64 ( text ) ) {
505513 return text
506514 }
507515 return encodeURIComponent ( btoa ( unescape ( encodeURIComponent ( text ) ) ) )
Original file line number Diff line number Diff line change 4343 v-model:value =" form.userdata"
4444 :placeholder =" apiParams.userdata.description" />
4545 </a-form-item >
46+ <a-form-item name =" isbase64" ref =" isbase64" :label =" $t('label.is.base64.encoded')" >
47+ <a-checkbox v-model:checked =" form.isbase64" ></a-checkbox >
48+ </a-form-item >
4649 <a-form-item name =" params" ref =" params" >
4750 <template #label >
4851 <tooltip-label :title =" $t('label.userdataparams')" :tooltip =" apiParams.params.description" />
@@ -147,7 +150,9 @@ export default {
147150 methods: {
148151 initForm () {
149152 this .formRef = ref ()
150- this .form = reactive ({})
153+ this .form = reactive ({
154+ isbase64: false
155+ })
151156 this .rules = reactive ({
152157 name: [{ required: true , message: this .$t (' message.error.name' ) }],
153158 userdata: [{ required: true , message: this .$t (' message.error.userdata' ) }]
@@ -204,7 +209,7 @@ export default {
204209 if (this .isValidValueForKey (values, ' account' ) && values .account .length > 0 ) {
205210 params .account = values .account
206211 }
207- params .userdata = this .$toBase64AndURIEncoded (values .userdata )
212+ params .userdata = values . isbase64 ? values . userdata : this .$toBase64AndURIEncoded (values .userdata )
208213
209214 if (values .params != null && values .params .length > 0 ) {
210215 var userdataparams = values .params .join (' ,' )
You can’t perform that action at this time.
0 commit comments