Skip to content

Commit

Permalink
Merge pull request ckeditor#14163 from ckeditor/ci/3253-simplify-lice…
Browse files Browse the repository at this point in the history
…nse-check-code

Internal (utils): Simplify the license check code.
  • Loading branch information
Dumluregn authored May 24, 2023
2 parents 06d4ccf + de9c115 commit d65b6df
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions packages/ckeditor5-utils/src/verifylicense.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,21 +33,21 @@ export default function verifyLicense( token: string | undefined ): VerifiedKeyS
// Please keep this code intact. Thank you for your understanding.

function oldTokenCheck( token: string ): VerifiedKeyStatus {
if ( token.match( /^[a-zA-Z0-9+/=$]+$/g ) && ( token.length >= 40 && token.length <= 255 ) ) {
if ( token.length >= 40 && token.length <= 255 ) {
return 'VALID';
} else {
return 'INVALID';
}
}

// TODO: issue ci#3175
let decryptedData = '';
let decryptedSecondElement = '';

if ( !token ) {
return 'INVALID';
}

let decryptedData = '';

try {
decryptedData = atob( token );
} catch ( e ) {
Expand Down Expand Up @@ -81,14 +81,10 @@ export default function verifyLicense( token: string | undefined ): VerifiedKeyS
return 'INVALID';
}

try {
// Must be a valid format.
atob( firstElement );
} catch ( e ) {
return 'INVALID';
}
let decryptedSecondElement = '';

try {
atob( firstElement );
decryptedSecondElement = atob( secondElement );
} catch ( e ) {
return 'INVALID';
Expand Down

0 comments on commit d65b6df

Please sign in to comment.