Skip to content

Commit

Permalink
Fixes #69344: Don't allow empty string for server.basePath config
Browse files Browse the repository at this point in the history
  • Loading branch information
rudolf committed Jun 17, 2020
1 parent 8a6aab3 commit 6ecd78a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/core/server/http/__snapshots__/http_config.test.ts.snap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions src/core/server/http/http_config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,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 = {
Expand Down
2 changes: 1 addition & 1 deletion src/core/server/http/http_config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) =>
Expand Down

0 comments on commit 6ecd78a

Please sign in to comment.