Skip to content

Commit 0eb6920

Browse files
authored
Merge pull request #328 from spadgett/3.7-sanitize-log
[enterprise-3.7] Sanitize HTML output for log viewer
2 parents cec10af + dcdc96c commit 0eb6920

File tree

4 files changed

+12
-12
lines changed

4 files changed

+12
-12
lines changed

dist/origin-web-common-ui.js

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

21282128
angular.module("openshiftCommonUI")
2129-
.factory("HTMLService", function(BREAKPOINTS) {
2129+
.factory("HTMLService", function($sanitize, BREAKPOINTS) {
21302130
var WINDOW_SIZE_XXS = 'xxs';
21312131
var WINDOW_SIZE_XS = 'xs';
21322132
var WINDOW_SIZE_SM = 'sm';
@@ -2216,13 +2216,13 @@ angular.module("openshiftCommonUI")
22162216
}
22172217

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

22242224
return "<a href=\"" + str + "\">" + str + "</a>";
2225-
});
2225+
}));
22262226
}
22272227
};
22282228
});

dist/origin-web-common.js

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

59155915
angular.module("openshiftCommonUI")
5916-
.factory("HTMLService", ["BREAKPOINTS", function(BREAKPOINTS) {
5916+
.factory("HTMLService", ["$sanitize", "BREAKPOINTS", function($sanitize, BREAKPOINTS) {
59175917
var WINDOW_SIZE_XXS = 'xxs';
59185918
var WINDOW_SIZE_XS = 'xs';
59195919
var WINDOW_SIZE_SM = 'sm';
@@ -6003,13 +6003,13 @@ angular.module("openshiftCommonUI")
60036003
}
60046004

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

60116011
return "<a href=\"" + str + "\">" + str + "</a>";
6012-
});
6012+
}));
60136013
}
60146014
};
60156015
}]);

dist/origin-web-common.min.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2616,7 +2616,7 @@ return {
26162616
startTour:startTour,
26172617
cancelTour:cancelTour
26182618
};
2619-
}), angular.module("openshiftCommonUI").factory("HTMLService", [ "BREAKPOINTS", function(BREAKPOINTS) {
2619+
}), angular.module("openshiftCommonUI").factory("HTMLService", [ "$sanitize", "BREAKPOINTS", function($sanitize, BREAKPOINTS) {
26202620
var WINDOW_SIZE_XXS = "xxs", WINDOW_SIZE_XS = "xs", WINDOW_SIZE_SM = "sm", WINDOW_SIZE_MD = "md", WINDOW_SIZE_LG = "lg";
26212621
return {
26222622
WINDOW_SIZE_XXS:WINDOW_SIZE_XXS,
@@ -2667,9 +2667,9 @@ return !0;
26672667
}
26682668
},
26692669
linkify:function(text, target, alreadyEscaped) {
2670-
return text ? (alreadyEscaped || (text = _.escape(text)), text.replace(/https?:\/\/[A-Za-z0-9._%+-]+[^\s<]*[^\s.,()\[\]{}<>"\u201d\u2019]/gm, function(str) {
2670+
return text ? (alreadyEscaped || (text = _.escape(text)), $sanitize(text.replace(/https?:\/\/[A-Za-z0-9._%+-]+[^\s<]*[^\s.,()\[\]{}<>"\u201d\u2019]/gm, function(str) {
26712671
return target ? '<a href="' + str + '" target="' + target + '">' + str + ' <i class="fa fa-external-link" aria-hidden="true"></i></a>' :'<a href="' + str + '">' + str + "</a>";
2672-
})) :text;
2672+
}))) :text;
26732673
}
26742674
};
26752675
} ]), 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)