File tree Expand file tree Collapse file tree 3 files changed +47
-1
lines changed
Expand file tree Collapse file tree 3 files changed +47
-1
lines changed Original file line number Diff line number Diff line change 1+ ## 4.0.1 - 2024-03-19
2+ ### Fixed
3+ - Escape unsafe HTML, this allows XML and HTML tags to display as text instead of render
4+
5+ ## 3.0.6 - 2022-05-10
6+ ### Fixed
7+ - Escape unsafe HTML, this allows XML and HTML tags to display as text instead of render
8+
19## 4.0.0 - 2022-07-11
210### Changed
311- Craft 4 release
Original file line number Diff line number Diff line change 11{
22 "name" : " ether/logs" ,
33 "description" : " Access logs from the CP" ,
4+ "version" : " 4.0.1" ,
45 "type" : " craft-plugin" ,
56 "minimum-stability" : " dev" ,
67 "require" : {
Original file line number Diff line number Diff line change @@ -63,6 +63,43 @@ function ($var) {
6363CSS ;
6464
6565 $ js = <<<JS
66+ /** Mixin to extend the String type with a method to escape unsafe characters
67+ * for use in HTML. Uses OWASP guidelines for safe strings in HTML.
68+ *
69+ * Credit: http://benv.ca/2012/10/4/you-are-probably-misusing-DOM-text-methods/
70+ * https://github.com/janl/mustache.js/blob/16ffa430a111dc293cd9ed899ecf9da3729f58bd/mustache.js#L62
71+ *
72+ 73+ *
74+ * @license http://opensource.org/licenses/MIT
75+ *
76+ * @version 1.0
77+ *
78+ * @mixin
79+ */
80+ (function(){
81+ "use strict";
82+
83+ function escapeHtml() {
84+ return this.replace(/[&<>"'\/]/g, function (s) {
85+ var entityMap = {
86+ "&": "&",
87+ "<": "<",
88+ ">": ">",
89+ '"': '"',
90+ "'": ''',
91+ "/": '/'
92+ };
93+
94+ return entityMap[s];
95+ });
96+ }
97+
98+ if (typeof(String.prototype.escapeHtml) !== 'function') {
99+ String.prototype.escapeHtml = escapeHtml;
100+ }
101+ })();
102+
66103const logElem = document.getElementById("__log");
67104
68105function streamLog (log) {
@@ -75,7 +112,7 @@ function streamLog (log) {
75112 }).then(data => data.text()).then(data => {
76113 let html = "";
77114
78- data.split("\\n").forEach(line => {
115+ data.escapeHtml(). split("\\n").forEach(line => {
79116 let m = /^(\d{4}(-\d{2}){2} (\d{2}:){2}\d{2}) (\[[^\]]+\]){3}\[([^\]]+)\]\[([^\]]+)\]/i.exec(line);
80117 if (m !== null) {
81118 let colour = "";
You can’t perform that action at this time.
0 commit comments