aboutsummaryrefslogtreecommitdiff
path: root/lib/util.js
diff options
context:
space:
mode:
authorcel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519>2018-08-25 22:35:46 -0700
committercel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519>2018-08-25 22:49:02 -0700
commitcfb593bcb2c4a7b62ed5bdf4a7833adf63428484 (patch)
treec133287827d520bedb44559622c56391b54f9a30 /lib/util.js
parentb957f72a8af1e561c82da17921147191a03cf9f1 (diff)
downloadpatchfoo-cfb593bcb2c4a7b62ed5bdf4a7833adf63428484.tar.gz
patchfoo-cfb593bcb2c4a7b62ed5bdf4a7833adf63428484.zip
Add about-self page
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, '&amp;')
+ .replace(/"/g, '&quot;')
.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
+}