Skip to content

Commit 8166fb9

Browse files
authored
Merge pull request #326 from spadgett/sanitize-log
Sanitize HTML output for log viewer
2 parents 3d27799 + 9d816ff commit 8166fb9

File tree

4 files changed

+27
-27
lines changed

4 files changed

+27
-27
lines changed

dist/origin-web-common-ui.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2604,7 +2604,7 @@ angular.module('openshiftCommonUI').factory('GuidedTourService', function() {
26042604
'use strict';
26052605

26062606
angular.module("openshiftCommonUI")
2607-
.factory("HTMLService", function(BREAKPOINTS) {
2607+
.factory("HTMLService", function($sanitize, BREAKPOINTS) {
26082608
var WINDOW_SIZE_XXS = 'xxs';
26092609
var WINDOW_SIZE_XS = 'xs';
26102610
var WINDOW_SIZE_SM = 'sm';
@@ -2694,13 +2694,13 @@ angular.module("openshiftCommonUI")
26942694
}
26952695

26962696
// Replace any URLs with links.
2697-
return text.replace(/https?:\/\/[A-Za-z0-9._%+-]+[^\s<]*[^\s.,()\[\]{}<>"\u201d\u2019]/gm, function(str) {
2697+
return $sanitize(text.replace(/https?:\/\/[A-Za-z0-9._%+-]+[^\s<]*[^\s.,()\[\]{}<>"\u201d\u2019]/gm, function(str) {
26982698
if (target) {
26992699
return "<a href=\"" + str + "\" target=\"" + target + "\">" + str + " <i class=\"fa fa-external-link\" aria-hidden=\"true\"></i></a>";
27002700
}
27012701

27022702
return "<a href=\"" + str + "\">" + str + "</a>";
2703-
});
2703+
}));
27042704
}
27052705
};
27062706
});

dist/origin-web-common.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5850,7 +5850,7 @@ angular.module('openshiftCommonUI').factory('GuidedTourService', function() {
58505850
'use strict';
58515851

58525852
angular.module("openshiftCommonUI")
5853-
.factory("HTMLService", ["BREAKPOINTS", function(BREAKPOINTS) {
5853+
.factory("HTMLService", ["$sanitize", "BREAKPOINTS", function($sanitize, BREAKPOINTS) {
58545854
var WINDOW_SIZE_XXS = 'xxs';
58555855
var WINDOW_SIZE_XS = 'xs';
58565856
var WINDOW_SIZE_SM = 'sm';
@@ -5940,13 +5940,13 @@ angular.module("openshiftCommonUI")
59405940
}
59415941

59425942
// Replace any URLs with links.
5943-
return text.replace(/https?:\/\/[A-Za-z0-9._%+-]+[^\s<]*[^\s.,()\[\]{}<>"\u201d\u2019]/gm, function(str) {
5943+
return $sanitize(text.replace(/https?:\/\/[A-Za-z0-9._%+-]+[^\s<]*[^\s.,()\[\]{}<>"\u201d\u2019]/gm, function(str) {
59445944
if (target) {
59455945
return "<a href=\"" + str + "\" target=\"" + target + "\">" + str + " <i class=\"fa fa-external-link\" aria-hidden=\"true\"></i></a>";
59465946
}
59475947

59485948
return "<a href=\"" + str + "\">" + str + "</a>";
5949-
});
5949+
}));
59505950
}
59515951
};
59525952
}]);

dist/origin-web-common.min.js

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2524,59 +2524,59 @@ closeTooltip: "x"
25242524
},
25252525
cancelTour: u
25262526
};
2527-
}), angular.module("openshiftCommonUI").factory("HTMLService", [ "BREAKPOINTS", function(e) {
2527+
}), angular.module("openshiftCommonUI").factory("HTMLService", [ "$sanitize", "BREAKPOINTS", function(e, t) {
25282528
return {
25292529
WINDOW_SIZE_XXS: "xxs",
25302530
WINDOW_SIZE_XS: "xs",
25312531
WINDOW_SIZE_SM: "sm",
25322532
WINDOW_SIZE_MD: "md",
25332533
WINDOW_SIZE_LG: "lg",
25342534
getBreakpoint: function() {
2535-
return window.innerWidth < e.screenXsMin ? "xxs" : window.innerWidth < e.screenSmMin ? "xs" : window.innerWidth < e.screenMdMin ? "sm" : window.innerWidth < e.screenLgMin ? "md" : "lg";
2535+
return window.innerWidth < t.screenXsMin ? "xxs" : window.innerWidth < t.screenSmMin ? "xs" : window.innerWidth < t.screenMdMin ? "sm" : window.innerWidth < t.screenLgMin ? "md" : "lg";
25362536
},
2537-
isWindowBelowBreakpoint: function(t) {
2538-
switch (t) {
2537+
isWindowBelowBreakpoint: function(e) {
2538+
switch (e) {
25392539
case "xxs":
25402540
return !1;
25412541

25422542
case "xs":
2543-
return window.innerWidth < e.screenXsMin;
2543+
return window.innerWidth < t.screenXsMin;
25442544

25452545
case "sm":
2546-
return window.innerWidth < e.screenSmMin;
2546+
return window.innerWidth < t.screenSmMin;
25472547

25482548
case "md":
2549-
return window.innerWidth < e.screenMdMin;
2549+
return window.innerWidth < t.screenMdMin;
25502550

25512551
case "lg":
2552-
return window.innerWidth < e.screenLgMin;
2552+
return window.innerWidth < t.screenLgMin;
25532553

25542554
default:
25552555
return !0;
25562556
}
25572557
},
2558-
isWindowAboveBreakpoint: function(t) {
2559-
switch (t) {
2558+
isWindowAboveBreakpoint: function(e) {
2559+
switch (e) {
25602560
case "xs":
2561-
return window.innerWidth >= e.screenXsMin;
2561+
return window.innerWidth >= t.screenXsMin;
25622562

25632563
case "sm":
2564-
return window.innerWidth >= e.screenSmMin;
2564+
return window.innerWidth >= t.screenSmMin;
25652565

25662566
case "md":
2567-
return window.innerWidth >= e.screenMdMin;
2567+
return window.innerWidth >= t.screenMdMin;
25682568

25692569
case "lg":
2570-
return window.innerWidth >= e.screenLgMin;
2570+
return window.innerWidth >= t.screenLgMin;
25712571

25722572
default:
25732573
return !0;
25742574
}
25752575
},
2576-
linkify: function(e, t, n) {
2577-
return e ? (n || (e = _.escape(e)), e.replace(/https?:\/\/[A-Za-z0-9._%+-]+[^\s<]*[^\s.,()\[\]{}<>"\u201d\u2019]/gm, function(e) {
2578-
return t ? '<a href="' + e + '" target="' + t + '">' + e + ' <i class="fa fa-external-link" aria-hidden="true"></i></a>' : '<a href="' + e + '">' + e + "</a>";
2579-
})) : e;
2576+
linkify: function(t, n, r) {
2577+
return t ? (r || (t = _.escape(t)), e(t.replace(/https?:\/\/[A-Za-z0-9._%+-]+[^\s<]*[^\s.,()\[\]{}<>"\u201d\u2019]/gm, function(e) {
2578+
return n ? '<a href="' + e + '" target="' + n + '">' + e + ' <i class="fa fa-external-link" aria-hidden="true"></i></a>' : '<a href="' + e + '">' + e + "</a>";
2579+
}))) : t;
25802580
}
25812581
};
25822582
} ]), angular.module("openshiftCommonUI").provider("NotificationsService", function() {

src/ui-services/htmlService.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict';
22

33
angular.module("openshiftCommonUI")
4-
.factory("HTMLService", function(BREAKPOINTS) {
4+
.factory("HTMLService", function($sanitize, BREAKPOINTS) {
55
var WINDOW_SIZE_XXS = 'xxs';
66
var WINDOW_SIZE_XS = 'xs';
77
var WINDOW_SIZE_SM = 'sm';
@@ -91,13 +91,13 @@ angular.module("openshiftCommonUI")
9191
}
9292

9393
// Replace any URLs with links.
94-
return text.replace(/https?:\/\/[A-Za-z0-9._%+-]+[^\s<]*[^\s.,()\[\]{}<>"\u201d\u2019]/gm, function(str) {
94+
return $sanitize(text.replace(/https?:\/\/[A-Za-z0-9._%+-]+[^\s<]*[^\s.,()\[\]{}<>"\u201d\u2019]/gm, function(str) {
9595
if (target) {
9696
return "<a href=\"" + str + "\" target=\"" + target + "\">" + str + " <i class=\"fa fa-external-link\" aria-hidden=\"true\"></i></a>";
9797
}
9898

9999
return "<a href=\"" + str + "\">" + str + "</a>";
100-
});
100+
}));
101101
}
102102
};
103103
});

0 commit comments

Comments
 (0)