cafe-utility 4.13.1 → 4.13.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +5 -3
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -834,17 +834,19 @@ function escapeHtml(string) {
|
|
|
834
834
|
}
|
|
835
835
|
|
|
836
836
|
const htmlEntityMap = {
|
|
837
|
+
'&': '&',
|
|
837
838
|
'"': '"',
|
|
839
|
+
''': "'",
|
|
838
840
|
'>': '>',
|
|
839
|
-
'<': '<'
|
|
841
|
+
'<': '<'
|
|
840
842
|
}
|
|
841
843
|
|
|
842
844
|
function decodeHtmlEntities(string) {
|
|
843
845
|
let buffer = string
|
|
844
846
|
.replace(/&#(\d+);/g, (_, dec) => String.fromCharCode(dec))
|
|
845
847
|
.replace(/&#x(\d+);/g, (_, hex) => String.fromCharCode(parseInt(hex, 16)))
|
|
846
|
-
for (const key of Object.
|
|
847
|
-
buffer = buffer.
|
|
848
|
+
for (const [key, value] of Object.entries(htmlEntityMap)) {
|
|
849
|
+
buffer = buffer.replaceAll(key, value)
|
|
848
850
|
}
|
|
849
851
|
return buffer
|
|
850
852
|
}
|