aboutsummaryrefslogtreecommitdiff
path: root/lib/util.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/util.js')
-rw-r--r--lib/util.js18
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/util.js b/lib/util.js
index 58bb4b0..c01d96c 100644
--- a/lib/util.js
+++ b/lib/util.js
@@ -165,6 +165,8 @@ u.customError = function (name) {
u.escapeHTML = function (html) {
if (!html) return ''
return html.toString('utf8')
+ .replace(/&/g, '&')
+ .replace(/"/g, '"')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
}
@@ -242,3 +244,19 @@ u.unwrapP = function(html) {
})
}
+u.estimateMessageSize = function (content) {
+ var draftMsg = {
+ key: '%0000000000000000000000000000000000000000000=.sha256',
+ value: {
+ previous: '%0000000000000000000000000000000000000000000=.sha256',
+ author: '@0000000000000000000000000000000000000000000=.ed25519',
+ sequence: 10000,
+ timestamp: 1000000000000,
+ hash: 'sha256',
+ content: content,
+ signature: '00000000000000000000000000000000000000000000000000000000000000000000000000000000000000==.sig.ed25519'
+ }
+ }
+
+ return JSON.stringify(draftMsg, null, 2).length
+}