How to use the escapeHtml function from hoek

Find comprehensive JavaScript hoek.escapeHtml code examples handpicked from public code repositorys.

228
229
230
231
232
233
234
235
236
### escapeHtml(string)

```javascript

var string = '<html> hey </html>';
var escapedString = Hoek.escapeHtml(string); // returns &lt;html&gt; hey &lt;/html&gt;
```

### escapeHeaderAttribute(attribute)
fork icon170
star icon1
watch icon33

117
118
119
120
121
122
123
124
125
126
127
128
129


        return format.replace(/\{\{(\!?)([^}]+)\}\}/g, ($0, isSecure, name) => {


            const value = Hoek.reach(this.context, name);
            const normalized = internals.stringify(value, wrapArrays);
            return (isSecure ? Hoek.escapeHtml(normalized) : normalized);
        });
    }


};
fork icon0
star icon1
watch icon0

65
66
67
68
69
70
71
72
73
74
75
76
internals.Boom.prototype.reformat = function () {


    this.response.payload.code = this.response.code;
    this.response.payload.error = Http.STATUS_CODES[this.response.code] || 'Unknown';
    if (this.message) {
        this.response.payload.message = Hoek.escapeHtml(this.message);         // Prevent XSS from error message
    }
};



fork icon0
star icon0
watch icon1

+ 85 other calls in file

123
124
125
126
127
128
129
130
131
132
133
134
135


        return format.replace(/\{\{(\!?)([^}]+)\}\}/g, ($0, isSecure, name) => {


            const value = Hoek.reach(this.context, name);
            const normalized = internals.stringify(value, wrapArrays);
            return (isSecure && this.options.escapeHtml ? Hoek.escapeHtml(normalized) : normalized);
        });
    }


};
fork icon0
star icon0
watch icon0