refactor: 💡 use allow-list in AppArch codebase (#71400)
This commit is contained in:
parent
79df8e01ad
commit
0c04d98206
|
@ -30,7 +30,7 @@ import {
|
|||
} from '../types';
|
||||
|
||||
const templateMatchRE = /{{([\s\S]+?)}}/g;
|
||||
const whitelistUrlSchemes = ['http://', 'https://'];
|
||||
const allowedUrlSchemes = ['http://', 'https://'];
|
||||
|
||||
const URL_TYPES = [
|
||||
{
|
||||
|
@ -161,7 +161,7 @@ export class UrlFormat extends FieldFormat {
|
|||
|
||||
return this.generateImgHtml(url, imageLabel);
|
||||
default:
|
||||
const inWhitelist = whitelistUrlSchemes.some((scheme) => url.indexOf(scheme) === 0);
|
||||
const inWhitelist = allowedUrlSchemes.some((scheme) => url.indexOf(scheme) === 0);
|
||||
if (!inWhitelist && !parsedUrl) {
|
||||
return url;
|
||||
}
|
||||
|
|
|
@ -116,7 +116,7 @@ describe('hash unhash url', () => {
|
|||
expect(mockStorage.length).toBe(3);
|
||||
});
|
||||
|
||||
it('hashes only whitelisted properties', () => {
|
||||
it('hashes only allow-listed properties', () => {
|
||||
const stateParamKey1 = '_g';
|
||||
const stateParamValue1 = '(yes:!t)';
|
||||
const stateParamKey2 = '_a';
|
||||
|
@ -227,7 +227,7 @@ describe('hash unhash url', () => {
|
|||
);
|
||||
});
|
||||
|
||||
it('unhashes only whitelisted properties', () => {
|
||||
it('un-hashes only allow-listed properties', () => {
|
||||
const stateParamKey1 = '_g';
|
||||
const stateParamValueHashed1 = 'h@4e60e02';
|
||||
const state1 = { yes: true };
|
||||
|
|
|
@ -35,7 +35,7 @@ export const hashUrl = createQueryReplacer(hashQuery);
|
|||
|
||||
// naive hack, but this allows to decouple these utils from AppState, GlobalState for now
|
||||
// when removing AppState, GlobalState and migrating to IState containers,
|
||||
// need to make sure that apps explicitly passing this whitelist to hash
|
||||
// need to make sure that apps explicitly passing this allow-list to hash
|
||||
const __HACK_HARDCODED_LEGACY_HASHABLE_PARAMS = ['_g', '_a', '_s'];
|
||||
function createQueryMapper(queryParamMapper: (q: string) => string | null) {
|
||||
return (
|
||||
|
|
Loading…
Reference in a new issue