Fixes #69344: Don't allow empty string for server.basePath config (#69377)

* Fixes #69344: Don't allow empty string for server.basePath config

* Remove unused basepath group
This commit is contained in:
Rudolf Meijering 2020-06-24 10:25:48 +02:00 committed by GitHub
parent 36b66a802e
commit c8608ed810
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 1 deletions

View file

@ -83,6 +83,8 @@ Object {
exports[`throws if basepath appends a slash 1`] = `"[basePath]: must start with a slash, don't end with one"`;
exports[`throws if basepath is an empty string 1`] = `"[basePath]: must start with a slash, don't end with one"`;
exports[`throws if basepath is missing prepended slash 1`] = `"[basePath]: must start with a slash, don't end with one"`;
exports[`throws if basepath is not specified, but rewriteBasePath is set 1`] = `"cannot use [rewriteBasePath] when [basePath] is not specified"`;

View file

@ -78,6 +78,14 @@ test('throws if basepath appends a slash', () => {
expect(() => httpSchema.validate(obj)).toThrowErrorMatchingSnapshot();
});
test('throws if basepath is an empty string', () => {
const httpSchema = config.schema;
const obj = {
basePath: '',
};
expect(() => httpSchema.validate(obj)).toThrowErrorMatchingSnapshot();
});
test('throws if basepath is not specified, but rewriteBasePath is set', () => {
const httpSchema = config.schema;
const obj = {

View file

@ -23,7 +23,7 @@ import { hostname } from 'os';
import { CspConfigType, CspConfig, ICspConfig } from '../csp';
import { SslConfig, sslSchema } from './ssl_config';
const validBasePathRegex = /(^$|^\/.*[^\/]$)/;
const validBasePathRegex = /^\/.*[^\/]$/;
const uuidRegexp = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-5][0-9a-f]{3}-[089ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
const match = (regex: RegExp, errorMsg: string) => (str: string) =>