cafe-utility 4.13.0 → 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 +8 -4
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -834,15 +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
|
-
let buffer = string
|
|
844
|
-
|
|
845
|
-
|
|
845
|
+
let buffer = string
|
|
846
|
+
.replace(/&#(\d+);/g, (_, dec) => String.fromCharCode(dec))
|
|
847
|
+
.replace(/&#x(\d+);/g, (_, hex) => String.fromCharCode(parseInt(hex, 16)))
|
|
848
|
+
for (const [key, value] of Object.entries(htmlEntityMap)) {
|
|
849
|
+
buffer = buffer.replaceAll(key, value)
|
|
846
850
|
}
|
|
847
851
|
return buffer
|
|
848
852
|
}
|