fix: turn on nullability in the code base.
This commit is contained in:

committed by
Tobias Bosch

parent
728c9d0632
commit
5293794316
@ -15,6 +15,6 @@ export {NgProbeToken} from './dom/debug/ng_probe';
|
||||
export {DOCUMENT} from './dom/dom_tokens';
|
||||
export {EVENT_MANAGER_PLUGINS, EventManager} from './dom/events/event_manager';
|
||||
export {HAMMER_GESTURE_CONFIG, HammerGestureConfig} from './dom/events/hammer_gestures';
|
||||
export {DomSanitizer, SafeHtml, SafeResourceUrl, SafeScript, SafeStyle, SafeUrl} from './security/dom_sanitization_service';
|
||||
export {DomSanitizer, SafeHtml, SafeResourceUrl, SafeScript, SafeStyle, SafeUrl, SafeValue} from './security/dom_sanitization_service';
|
||||
export * from './private_export';
|
||||
export {VERSION} from './version';
|
||||
|
@ -100,8 +100,6 @@ export abstract class DomSanitizer implements Sanitizer {
|
||||
* by replacing URLs that have an unsafe protocol part (such as `javascript:`). The implementation
|
||||
* is responsible to make sure that the value can definitely be safely used in the given context.
|
||||
*/
|
||||
abstract sanitize(context: SecurityContext, value: null): null;
|
||||
abstract sanitize(context: SecurityContext, value: SafeValue|string): string;
|
||||
abstract sanitize(context: SecurityContext, value: SafeValue|string|null): string|null;
|
||||
|
||||
/**
|
||||
@ -154,14 +152,11 @@ export abstract class DomSanitizer implements Sanitizer {
|
||||
export class DomSanitizerImpl extends DomSanitizer {
|
||||
constructor(@Inject(DOCUMENT) private _doc: any) { super(); }
|
||||
|
||||
sanitize(context: SecurityContext, value: null): null;
|
||||
sanitize(context: SecurityContext, value: SafeValue|string): string;
|
||||
sanitize(context: SecurityContext, value: SafeValue|string|null): string|null;
|
||||
sanitize(ctx: SecurityContext, value: any): string|null {
|
||||
sanitize(ctx: SecurityContext, value: SafeValue|string|null): string|null {
|
||||
if (value == null) return null;
|
||||
switch (ctx) {
|
||||
case SecurityContext.NONE:
|
||||
return value;
|
||||
return value as string;
|
||||
case SecurityContext.HTML:
|
||||
if (value instanceof SafeHtmlImpl) return value.changingThisBreaksApplicationSecurity;
|
||||
this.checkNotSafeValue(value, 'HTML');
|
||||
@ -169,7 +164,7 @@ export class DomSanitizerImpl extends DomSanitizer {
|
||||
case SecurityContext.STYLE:
|
||||
if (value instanceof SafeStyleImpl) return value.changingThisBreaksApplicationSecurity;
|
||||
this.checkNotSafeValue(value, 'Style');
|
||||
return sanitizeStyle(value);
|
||||
return sanitizeStyle(value as string);
|
||||
case SecurityContext.SCRIPT:
|
||||
if (value instanceof SafeScriptImpl) return value.changingThisBreaksApplicationSecurity;
|
||||
this.checkNotSafeValue(value, 'Script');
|
||||
|
Reference in New Issue
Block a user