Skip to content
This repository was archived by the owner on Mar 6, 2023. It is now read-only.

Commit 09e65cf

Browse files
committed
Updated the sanitizer implementation to handle more cases.
First it stinks that everything is not sanitized but the sanitizer doesn't handle every use case like c# generics etc.. So we must fall back or have a bad user experience.
1 parent dc66785 commit 09e65cf

File tree

2 files changed

+26
-6
lines changed

2 files changed

+26
-6
lines changed

src/components/simple-stack-trace/simple-stack-trace-directive.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
function buildStackFrames(exceptions) {
1111
var frames = '';
1212
for (var index = 0; index < exceptions.length; index++) {
13-
frames += '<div class="stack-frame">' + $sanitize(exceptions[index].stack_trace.replace(' ', ''));
13+
frames += '<div class="stack-frame">' + sanitize(exceptions[index].stack_trace.replace(' ', ''));
1414

1515
if (index < (exceptions.length - 1)) {
1616
frames += '<div>--- End of inner exception stack trace ---</div>';
@@ -35,9 +35,9 @@
3535
header += ' ---> ';
3636
}
3737

38-
header += '<span class="ex-type">' + $sanitize(exceptions[index].type) + '</span>';
38+
header += '<span class="ex-type">' + sanitize(exceptions[index].type) + '</span>';
3939
if (exceptions[index].message) {
40-
header += '<span class="ex-message">: ' + $sanitize(exceptions[index].message) + '</span>';
40+
header += '<span class="ex-message">: ' + sanitize(exceptions[index].message) + '</span>';
4141
}
4242

4343
header += '</span>';
@@ -46,6 +46,16 @@
4646
return header;
4747
}
4848

49+
function sanitize(input) {
50+
try {
51+
return $sanitize(input);
52+
} catch (e) {
53+
// TODO: Log this to Exceptionless.
54+
}
55+
56+
return input;
57+
}
58+
4959
return {
5060
bindToController: true,
5161
restrict: 'E',

src/components/stack-trace/stack-trace-directive.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
}
7474
}
7575

76-
return $sanitize(result + '\r\n');
76+
return sanitize(result + '\r\n');
7777
}
7878

7979
function buildStackFrames(exceptions) {
@@ -114,9 +114,9 @@
114114
header += ' ---> ';
115115
}
116116

117-
header += '<span class="ex-type">' + $sanitize(exceptions[index].type) + '</span>';
117+
header += '<span class="ex-type">' + sanitize(exceptions[index].type) + '</span>';
118118
if (exceptions[index].message) {
119-
header += '<span class="ex-message">: ' + $sanitize(exceptions[index].message) + '</span>';
119+
header += '<span class="ex-message">: ' + sanitize(exceptions[index].message) + '</span>';
120120
}
121121

122122
header += '</span>';
@@ -125,6 +125,16 @@
125125
return header;
126126
}
127127

128+
function sanitize(input) {
129+
try {
130+
return $sanitize(input);
131+
} catch (e) {
132+
// TODO: Log this to Exceptionless.
133+
}
134+
135+
return input;
136+
}
137+
128138
return {
129139
bindToController: true,
130140
restrict: 'E',

0 commit comments

Comments
 (0)