Added mail message padding support

master
Kevin Froman 2020-02-19 01:57:56 -06:00
parent 83ef9dc3ca
commit 9f1790a601
5 changed files with 46 additions and 5 deletions

View File

@ -18,7 +18,7 @@ QUOTES = [
"James Bamford"), "James Bamford"),
("Freedom of the press is guaranteed only to those who own one", ("Freedom of the press is guaranteed only to those who own one",
"A. J. Liebling"), "A. J. Liebling"),
("We kill people based on metadata", ("\"Probably better than nothing\"",
"") "")
] ]
shuffle(QUOTES) shuffle(QUOTES)

View File

@ -160,9 +160,9 @@
</div> </div>
<div class="column is-2"> <div class="column is-2">
<div class="field"> <div class="field">
<input id="messagePadding" type="checkbox" <input id="messagePaddingSetting" type="checkbox"
class="switch is-rounded is-warning" checked> class="switch is-rounded is-warning" checked>
<label for="messagePadding"></label> <label for="messagePaddingSetting"></label>
</div> </div>
</div> </div>
</div> </div>

View File

@ -11,4 +11,7 @@ fetch('/config/get/mail', {
if (mailSettings.default_forward_secrecy === false){ if (mailSettings.default_forward_secrecy === false){
document.getElementById('forwardSecrecySetting').checked = false document.getElementById('forwardSecrecySetting').checked = false
} }
if (mailSettings.use_padding === false){
document.getElementById('messagePaddingSetting').checked = false
}
}) })

View File

@ -88,6 +88,21 @@ function openThread(bHash, sender, date, sigBool, pubkey, subjectLine){
document.getElementById('fromUser').value = sender || 'Anonymous' document.getElementById('fromUser').value = sender || 'Anonymous'
document.getElementById('fromUser').value = pubkey || '' document.getElementById('fromUser').value = pubkey || ''
document.getElementById('subjectView').innerText = subjectLine document.getElementById('subjectView').innerText = subjectLine
resp = resp.split("")
let zeroCount = 0
for (x = resp.length - 1; x != 0; x--){
if (resp[x] == "0"){
zeroCount += 1
}
else{
break
}
}
resp.splice(resp.length - zeroCount, zeroCount)
resp = resp.join("")
messageDisplay.innerText = resp messageDisplay.innerText = resp
var sigEl = document.getElementById('sigValid') var sigEl = document.getElementById('sigValid')
var sigMsg = 'signature' var sigMsg = 'signature'

View File

@ -23,12 +23,35 @@ to = document.getElementById('draftID')
subject = document.getElementById('draftSubject') subject = document.getElementById('draftSubject')
friendPicker = document.getElementById('friendSelect') friendPicker = document.getElementById('friendSelect')
function sendMail(toData, message, subject){ function utf8Length(s) {
var size = encodeURIComponent(s).match(/%[89ABab]/g);
return s.length + (size ? size.length : 0);
}
postData = {'message': message, 'to': toData, 'type': 'pm', 'encrypt': true, 'meta': JSON.stringify({'subject': subject})} function padString(string_data, round_nearest_byte_exponent = 3){
if (utf8Length(string_data) === 0){
string_data += '0'
}
let round_size = 10 ** round_nearest_byte_exponent
while (utf8Length(string_data) % round_size > 0){
string_data += '0'
}
return string_data
}
function sendMail(toData, message, subject){
let meta = {'subject': subject}
if (document.getElementById('messagePaddingSetting').checked){
message = padString(message)
}
postData = {'message': message, 'to': toData, 'type': 'pm', 'encrypt': true, 'meta': JSON.stringify(meta)}
postData.forward = document.getElementById('forwardSecrecySetting').checked postData.forward = document.getElementById('forwardSecrecySetting').checked
postData = JSON.stringify(postData) postData = JSON.stringify(postData)
sendForm.style.display = 'none' sendForm.style.display = 'none'
fetch('/insertblock', { fetch('/insertblock', {
method: 'POST', method: 'POST',
body: postData, body: postData,