Skip to content

Commit db8b4c5

Browse files
authored
WEB-824: Fix null handling in PrettyPrintPipe (#3339)
Guard against null/undefined/non-string values; return empty string to prevent runtime crash and objects/numbers reaching [innerHTML] consumer. Made-with: Cursor
1 parent 2c0b15d commit db8b4c5

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/app/pipes/pretty-print.pipe.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ import * as vkbeautify from 'vkbeautify';
1212
@Pipe({ name: 'prettyPrint' })
1313
export class PrettyPrintPipe implements PipeTransform {
1414
transform(value: any) {
15+
if (value == null || typeof value !== 'string') {
16+
return '';
17+
}
1518
if (value.charAt(0) === '{' && value.charAt(value.length - 1) === '}') {
1619
try {
1720
return vkbeautify.json(value);

0 commit comments

Comments
 (0)