Tools: Improved HTML escape in git-changelog

pull/4012/head
Laurent Cozic 2020-10-31 13:05:46 +00:00
parent d19796f14c
commit 08c2a7ad64
1 changed files with 5 additions and 4 deletions

View File

@ -10,12 +10,13 @@ const { execCommand, githubUsername } = require('./tool-utils.js');
// From https://stackoverflow.com/a/6234804/561309 // From https://stackoverflow.com/a/6234804/561309
function escapeHtml(unsafe) { function escapeHtml(unsafe) {
// We only escape <> as this is enough for Markdown
return unsafe return unsafe
.replace(/&/g, '&amp;') // .replace(/&/g, '&amp;')
.replace(/</g, '&lt;') .replace(/</g, '&lt;')
.replace(/>/g, '&gt;') .replace(/>/g, '&gt;');
.replace(/"/g, '&quot;') // .replace(/"/g, '&quot;')
.replace(/'/g, '&#039;'); // .replace(/'/g, '&#039;');
} }
async function gitLog(sinceTag) { async function gitLog(sinceTag) {