File tree Expand file tree Collapse file tree 7 files changed +14
-40
lines changed
Expand file tree Collapse file tree 7 files changed +14
-40
lines changed Original file line number Diff line number Diff line change @@ -484,6 +484,14 @@ export const genericUtilPlugin = {
484484 const regexExp = / ^ [ 0 - 9 a - f A - F ] { 8 } \b - [ 0 - 9 a - f A - F ] { 4 } \b - [ 0 - 9 a - f A - F ] { 4 } \b - [ 0 - 9 a - f A - F ] { 4 } \b - [ 0 - 9 a - f A - F ] { 12 } $ / gi
485485 return regexExp . test ( uuid )
486486 }
487+
488+ app . config . globalProperties . $toBase64AndURIEncoded = function ( text ) {
489+ const base64regex = / ^ ( [ 0 - 9 a - z A - Z + / ] { 4 } ) * ( ( [ 0 - 9 a - z A - Z + / ] { 2 } = = ) | ( [ 0 - 9 a - z A - Z + / ] { 3 } = ) ) ? $ /
490+ if ( base64regex . test ( text ) ) {
491+ return text
492+ }
493+ return encodeURIComponent ( btoa ( unescape ( encodeURIComponent ( text ) ) ) )
494+ }
487495 }
488496}
489497
Original file line number Diff line number Diff line change @@ -519,7 +519,7 @@ export default {
519519 params .autoscaleuserid = this .autoscaleuserid
520520 }
521521 if (this .userdata && this .userdata .length > 0 ) {
522- params .userdata = encodeURIComponent ( btoa ( this .sanitizeReverse (this .userdata )) )
522+ params .userdata = this .$toBase64AndURIEncoded (this .userdata )
523523 }
524524
525525 const httpMethod = params .userdata ? ' POST' : ' GET'
@@ -539,14 +539,6 @@ export default {
539539 this .loading = false
540540 })
541541 },
542- sanitizeReverse (value ) {
543- const reversedValue = value
544- .replace (/ &/ g , ' &' )
545- .replace (/ </ g , ' <' )
546- .replace (/ >/ g , ' >' )
547-
548- return reversedValue
549- },
550542 decodeUserData (userdata ) {
551543 const decodedData = Buffer .from (userdata, ' base64' )
552544 return decodedData .toString (' utf-8' )
Original file line number Diff line number Diff line change @@ -2425,7 +2425,7 @@ export default {
24252425 createVmGroupData .keypairs = this .sshKeyPairs .join (' ,' )
24262426 createVmGroupData .affinitygroupids = (values .affinitygroupids || []).join (' ,' )
24272427 if (values .userdata && values .userdata .length > 0 ) {
2428- createVmGroupData .userdata = encodeURIComponent ( btoa ( this .sanitizeReverse (values .userdata )) )
2428+ createVmGroupData .userdata = this .$toBase64AndURIEncoded (values .userdata )
24292429 }
24302430
24312431 // vm profile details
@@ -2702,14 +2702,6 @@ export default {
27022702 this .params [name].options = { ... this .params [name].options , ... options }
27032703 this .fetchOptions (this .params [name], name)
27042704 },
2705- sanitizeReverse (value ) {
2706- const reversedValue = value
2707- .replace (/ &/ g , ' &' )
2708- .replace (/ </ g , ' <' )
2709- .replace (/ >/ g , ' >' )
2710-
2711- return reversedValue
2712- },
27132705 fetchTemplateNics (template ) {
27142706 var nics = []
27152707 this .nicToNetworkSelection = []
Original file line number Diff line number Diff line change @@ -836,7 +836,6 @@ import UserDataSelection from '@views/compute/wizard/UserDataSelection'
836836import SecurityGroupSelection from ' @views/compute/wizard/SecurityGroupSelection'
837837import TooltipLabel from ' @/components/widgets/TooltipLabel'
838838import InstanceNicsNetworkSelectListView from ' @/components/view/InstanceNicsNetworkSelectListView.vue'
839- import { sanitizeReverse } from ' @/utils/util'
840839
841840export default {
842841 name: ' Wizard' ,
@@ -1971,7 +1970,7 @@ export default {
19711970 deployVmData .iothreadsenabled = values .iothreadsenabled
19721971 deployVmData .iodriverpolicy = values .iodriverpolicy
19731972 if (values .userdata && values .userdata .length > 0 ) {
1974- deployVmData .userdata = encodeURIComponent ( btoa ( sanitizeReverse ( values .userdata )) )
1973+ deployVmData .userdata = this . $toBase64AndURIEncoded ( values .userdata )
19751974 }
19761975 // step 2: select template/iso
19771976 if (this .tabKey === ' templateid' ) {
Original file line number Diff line number Diff line change 123123import { ref , reactive , toRaw } from ' vue'
124124import { api } from ' @/api'
125125import TooltipLabel from ' @/components/widgets/TooltipLabel'
126- import { sanitizeReverse } from ' @/utils/util'
127126
128127export default {
129128 name: ' EditVM' ,
@@ -317,7 +316,7 @@ export default {
317316 params .group = values .group
318317 }
319318 if (values .userdata && values .userdata .length > 0 ) {
320- params .userdata = encodeURIComponent ( btoa ( sanitizeReverse ( values .userdata )) )
319+ params .userdata = this . $toBase64AndURIEncoded ( values .userdata )
321320 }
322321 this .loading = true
323322
Original file line number Diff line number Diff line change @@ -184,14 +184,6 @@ export default {
184184 handleDomainChanged (domain ) {
185185 this .selectedDomain = domain
186186 },
187- sanitizeReverse (value ) {
188- const reversedValue = value
189- .replace (/ &/ g , ' &' )
190- .replace (/ </ g , ' <' )
191- .replace (/ >/ g , ' >' )
192-
193- return reversedValue
194- },
195187 handleSubmit (e ) {
196188 e .preventDefault ()
197189 if (this .loading ) return
@@ -209,7 +201,7 @@ export default {
209201 if (this .isValidValueForKey (values, ' account' ) && values .account .length > 0 ) {
210202 params .account = values .account
211203 }
212- params .userdata = encodeURIComponent ( btoa ( this .sanitizeReverse (values .userdata )) )
204+ params .userdata = this .$toBase64AndURIEncoded (values .userdata )
213205
214206 if (values .params != null && values .params .length > 0 ) {
215207 var userdataparams = values .params .join (' ,' )
Original file line number Diff line number Diff line change @@ -289,14 +289,6 @@ export default {
289289 this [type] = key
290290 this .userDataParams = []
291291 },
292- sanitizeReverse (value ) {
293- const reversedValue = value
294- .replace (/ &/ g , ' &' )
295- .replace (/ </ g , ' <' )
296- .replace (/ >/ g , ' >' )
297-
298- return reversedValue
299- },
300292 isUserAllowedToListUserDatas () {
301293 return Boolean (' listUserData' in this .$store .getters .apis )
302294 },
@@ -346,7 +338,7 @@ export default {
346338 id: this .resource .id
347339 }
348340 if (values .userdata && values .userdata .length > 0 ) {
349- params .userdata = encodeURIComponent ( btoa ( this .sanitizeReverse (values .userdata )) )
341+ params .userdata = this .$toBase64AndURIEncoded (values .userdata )
350342 }
351343 if (values .userdataid ) {
352344 params .userdataid = values .userdataid
You can’t perform that action at this time.
0 commit comments