main
Bob Mottram 2021-03-01 10:23:38 +00:00
commit c5e9178917
14 changed files with 121 additions and 52 deletions

View File

@ -819,7 +819,8 @@ def htmlEditBlog(mediaInstance: bool, translate: {},
editBlogForm += \
' <textarea id="message" name="message" style="height:' + \
str(messageBoxHeight) + 'px">' + contentStr + '</textarea>'
str(messageBoxHeight) + 'px" spellcheck="true">' + \
contentStr + '</textarea>'
editBlogForm += dateAndLocation
if not mediaInstance:
editBlogForm += editBlogImageSection

View File

@ -979,16 +979,21 @@ def saveMediaInFormPOST(mediaBytes, debug: bool,
return filename, attachmentMediaType
def extractTextFieldsInPOST(postBytes, boundary, debug: bool) -> {}:
def extractTextFieldsInPOST(postBytes, boundary, debug: bool,
unitTestData=None) -> {}:
"""Returns a dictionary containing the text fields of a http form POST
The boundary argument comes from the http header
"""
msg = email.parser.BytesParser().parsebytes(postBytes)
if not unitTestData:
msgBytes = email.parser.BytesParser().parsebytes(postBytes)
messageFields = msgBytes.get_payload(decode=True).decode('utf-8')
else:
messageFields = unitTestData
if debug:
print('DEBUG: POST arriving ' +
msg.get_payload(decode=True).decode('utf-8'))
messageFields = msg.get_payload(decode=True)
messageFields = messageFields.decode('utf-8').split(boundary)
print('DEBUG: POST arriving ' + messageFields)
messageFields = messageFields.split(boundary)
fields = {}
# examine each section of the POST, separated by the boundary
for f in messageFields:
@ -1002,7 +1007,8 @@ def extractTextFieldsInPOST(postBytes, boundary, debug: bool) -> {}:
postKey = postStr.split('"', 1)[0]
postValueStr = postStr.split('"', 1)[1]
if ';' in postValueStr:
continue
if postKey != 'message':
continue
if '\r\n' not in postValueStr:
continue
postLines = postValueStr.split('\r\n')

View File

@ -13792,6 +13792,7 @@ class PubServer(BaseHTTPRequestHandler):
"editblogpost", "newreminder", "newevent")
for currPostType in postTypes:
if not authorized:
print('POST was not authorized')
break
postRedirect = self.server.defaultTimeline
@ -13805,6 +13806,7 @@ class PubServer(BaseHTTPRequestHandler):
callingDomain, cookie,
authorized)
if pageNumber:
print(currPostType + ' post received')
nickname = self.path.split('/users/')[1]
if '?' in nickname:
nickname = nickname.split('?')[0]

View File

@ -14,10 +14,16 @@
<p>This instance will not host content containing sexism, racism, casteism, homophobia, transphobia, misogyny, antisemitism or other forms of bigotry or discrimination on the basis of nationality or immigration status. Claims that transgressions of this type were intended to be "ironic" will be treated as a terms of service violation.</p>
<p>Even if not conspicuously discriminatory, expressions of support for organizations with discrminatory agendas are not permitted on this instance. These include, but are not limited to, racial supremacist groups, the redpill/incel movement and anti-LGBT or anti-immigrant campaigns.</p>
<p>Depictions of injury, death or medical procedures are not permitted.</p>
<p>Violent or abusive content will be subject to moderation and is likely to be removed.</p>
<p>Content of a sexual nature may be published providing that only consenting adults (aged 18 or over) are depicted and an appropriate content warning message is added. Posting sexual content without a content warning is a terms of service violation. Sexual content is defined both as photographs of real people and also artistic or fictional depictions, edited/generated photos or narratives.</p>
<p>Moderators rely upon your reports. Don't assume that something of concern has already been reported. It's better for there to be duplicate reports than for something potentially damaging to go unreported.</p>
<p>Content found to be non-compliant with this policy will be removed and any accounts on this instance producing, repeating or linking to such content will be deleted typically without prior notification.</p>
<h3>Federation Policy</h3>

View File

@ -1370,8 +1370,11 @@ def _receiveAnnounce(recentPostsCache: {},
YTReplacementDomain,
allowLocalNetworkAccess)
if not postJsonObject:
if domain not in messageJson['object'] and \
onionDomain not in messageJson['object']:
notInOnion = True
if onionDomain:
if onionDomain in messageJson['object']:
notInOnion = False
if domain not in messageJson['object'] and notInOnion:
if os.path.isfile(postFilename):
# if the announce can't be downloaded then remove it
os.remove(postFilename)

View File

@ -77,6 +77,7 @@ from inbox import jsonPostAllowsComments
from inbox import validInbox
from inbox import validInboxFilenames
from categories import guessHashtagCategory
from content import extractTextFieldsInPOST
from content import validHashTag
from content import htmlReplaceEmailQuote
from content import htmlReplaceQuoteMarks
@ -3330,9 +3331,47 @@ def testMarkdownToHtml():
'Or <img class="markdownImage" src="/cat.jpg" alt="pounce" />.'
def testExtractTextFieldsInPOST():
print('testExtractTextFieldsInPOST')
boundary = '-----------------------------116202748023898664511855843036'
formData = '-----------------------------116202748023898664511855' + \
'843036\r\nContent-Disposition: form-data; name="submitPost"' + \
'\r\n\r\nSubmit\r\n-----------------------------116202748023' + \
'898664511855843036\r\nContent-Disposition: form-data; name=' + \
'"subject"\r\n\r\n\r\n-----------------------------116202748' + \
'023898664511855843036\r\nContent-Disposition: form-data; na' + \
'me="message"\r\n\r\nThis is a ; test\r\n-------------------' + \
'----------116202748023898664511855843036\r\nContent-Disposi' + \
'tion: form-data; name="commentsEnabled"\r\n\r\non\r\n------' + \
'-----------------------116202748023898664511855843036\r\nCo' + \
'ntent-Disposition: form-data; name="eventDate"\r\n\r\n\r\n' + \
'-----------------------------116202748023898664511855843036' + \
'\r\nContent-Disposition: form-data; name="eventTime"\r\n\r' + \
'\n\r\n-----------------------------116202748023898664511855' + \
'843036\r\nContent-Disposition: form-data; name="location"' + \
'\r\n\r\n\r\n-----------------------------116202748023898664' + \
'511855843036\r\nContent-Disposition: form-data; name=' + \
'"imageDescription"\r\n\r\n\r\n-----------------------------' + \
'116202748023898664511855843036\r\nContent-Disposition: ' + \
'form-data; name="attachpic"; filename=""\r\nContent-Type: ' + \
'application/octet-stream\r\n\r\n\r\n----------------------' + \
'-------116202748023898664511855843036--\r\n'
debug = False
fields = extractTextFieldsInPOST(None, boundary, debug, formData)
assert fields['submitPost'] == 'Submit'
assert fields['subject'] == ''
assert fields['commentsEnabled'] == 'on'
assert fields['eventDate'] == ''
assert fields['eventTime'] == ''
assert fields['location'] == ''
assert fields['imageDescription'] == ''
assert fields['message'] == 'This is a ; test'
def runAllTests():
print('Running tests...')
testFunctions()
testExtractTextFieldsInPOST()
testMarkdownToHtml()
testValidHashTag()
testPrepareHtmlPostNickname()

View File

@ -1,10 +1,6 @@
88888888888 88
88 ""
88
88aaaaa 8b,dPPYba, 88 ,adPPYba, 8b d8 ,adPPYba, 8b,dPPYba,
88""""" 88P' "8a 88 a8" "" `8b d8' a8" "8a 88P' `"8a
88 88 d8 88 8b `8b d8' 8b d8 88 88
88 88b, ,a8" 88 "8a, ,aa `8b,d8' "8a, ,a8" 88 88
88888888888 88`YbbdP"' 88 `"Ybbd8"' Y88' `"YbbdP"' 88 88
88 d8'
88 d8'
_____ __ _ __ _ _ E P I C Y O N
|_ _| /_/ | | /_/ _ __ ___ __ _ | |_ (_) __ _ _ _ ___
| | / _ \ | | / _ \ | '_ ` _ \ / _` | | __| | | / _` | | | | | / _ \
| | | __/ | | | __/ | | | | | | | (_| | | |_ | | | (_| | | |_| | | __/
|_| \___| |_| \___| |_| |_| |_| \__,_| \__| |_| \__, | \__,_| \___|
|_|

View File

@ -401,7 +401,8 @@ def htmlEditLinks(cssCache: {}, translate: {}, baseDir: str, path: str,
translate['One link per line. Description followed by the link.'] + \
'<br>'
editLinksForm += \
' <textarea id="message" name="editedLinks" style="height:80vh">' + \
' <textarea id="message" name="editedLinks" ' + \
'style="height:80vh" spellcheck="false">' + \
linksStr + '</textarea>'
editLinksForm += \
'</div>'
@ -424,7 +425,8 @@ def htmlEditLinks(cssCache: {}, translate: {}, baseDir: str, path: str,
'<br>'
editLinksForm += \
' <textarea id="message" name="editedAbout" ' + \
'style="height:100vh">' + aboutStr + '</textarea>'
'style="height:100vh" spellcheck="true" autocomplete="on">' + \
aboutStr + '</textarea>'
editLinksForm += \
'</div>'
@ -442,7 +444,8 @@ def htmlEditLinks(cssCache: {}, translate: {}, baseDir: str, path: str,
'<br>'
editLinksForm += \
' <textarea id="message" name="editedTOS" ' + \
'style="height:100vh">' + TOSStr + '</textarea>'
'style="height:100vh" spellcheck="true" autocomplete="on">' + \
TOSStr + '</textarea>'
editLinksForm += \
'</div>'

View File

@ -577,7 +577,8 @@ def htmlEditNewswire(cssCache: {}, translate: {}, baseDir: str, path: str,
'<br>'
editNewswireForm += \
' <textarea id="message" name="editedNewswire" ' + \
'style="height:80vh">' + newswireStr + '</textarea>'
'style="height:80vh" spellcheck="false">' + \
newswireStr + '</textarea>'
filterStr = ''
filterFilename = \
@ -592,8 +593,8 @@ def htmlEditNewswire(cssCache: {}, translate: {}, baseDir: str, path: str,
editNewswireForm += ' <br><label class="labels">' + \
translate['One per line'] + '</label>'
editNewswireForm += ' <textarea id="message" ' + \
'name="filteredWordsNewswire" style="height:50vh">' + \
filterStr + '</textarea>\n'
'name="filteredWordsNewswire" style="height:50vh" ' + \
'spellcheck="true">' + filterStr + '</textarea>\n'
hashtagRulesStr = ''
hashtagRulesFilename = \
@ -612,7 +613,7 @@ def htmlEditNewswire(cssCache: {}, translate: {}, baseDir: str, path: str,
'https://gitlab.com/bashrc2/epicyon/-/raw/main/hashtagrules.txt' + \
'">' + translate['See instructions'] + '</a>\n'
editNewswireForm += ' <textarea id="message" ' + \
'name="hashtagRulesList" style="height:80vh">' + \
'name="hashtagRulesList" style="height:80vh" spellcheck="false">' + \
hashtagRulesStr + '</textarea>\n'
editNewswireForm += \
@ -687,7 +688,8 @@ def htmlEditNewsPost(cssCache: {}, translate: {}, baseDir: str, path: str,
newsPostContent = postJsonObject['object']['content']
editNewsPostForm += \
' <textarea id="message" name="editedNewsPost" ' + \
'style="height:600px">' + newsPostContent + '</textarea>'
'style="height:600px" spellcheck="true">' + \
newsPostContent + '</textarea>'
editNewsPostForm += \
'</div>'

View File

@ -555,7 +555,8 @@ def htmlNewPost(cssCache: {}, mediaInstance: bool, translate: {},
dateAndLocation += \
' <textarea id="message" ' + \
'name="repliesModerationOption" style="height:' + \
str(messageBoxHeight) + 'px"></textarea>\n'
str(messageBoxHeight) + 'px" spellcheck="true" ' + \
'autocomplete="on"></textarea>\n'
dateAndLocation += '</div>\n'
dateAndLocation += '<div class="container">\n'
dateAndLocation += '<label class="labels">' + \
@ -753,7 +754,9 @@ def htmlNewPost(cssCache: {}, mediaInstance: bool, translate: {},
newPostForm += \
' <textarea id="message" name="message" style="height:' + \
str(messageBoxHeight) + 'px"' + selectedStr + '></textarea>\n'
str(messageBoxHeight) + 'px"' + selectedStr + \
' spellcheck="true" autocomplete="on">' + \
'</textarea>\n'
newPostForm += extraFields + citationsStr + dateAndLocation
if not mediaInstance or replyStr:
newPostForm += newPostImageSection

View File

@ -337,7 +337,7 @@ def htmlModerationInfo(cssCache: {}, translate: {},
translate['These are currently suspended']
infoForm += \
' <textarea id="message" ' + \
'name="suspended" style="height:200px">' + \
'name="suspended" style="height:200px" spellcheck="false">' + \
suspendedStr + '</textarea>\n'
infoForm += '</div>\n'
infoShown = True
@ -355,7 +355,7 @@ def htmlModerationInfo(cssCache: {}, translate: {},
translate[msgStr1]
infoForm += \
' <textarea id="message" ' + \
'name="blocked" style="height:700px">' + \
'name="blocked" style="height:700px" spellcheck="false">' + \
blockedStr + '</textarea>\n'
infoForm += '</div>\n'
infoShown = True
@ -370,7 +370,7 @@ def htmlModerationInfo(cssCache: {}, translate: {},
translate['Filtered words'] + '</b>'
infoForm += \
' <textarea id="message" ' + \
'name="filtered" style="height:700px">' + \
'name="filtered" style="height:700px" spellcheck="true">' + \
filteredStr + '</textarea>\n'
infoForm += '</div>\n'
infoShown = True

View File

@ -376,7 +376,7 @@ def htmlPersonOptions(defaultTimeline: str,
translate['Submit'] + '</button><br>\n'
optionsStr += \
' <textarea id="message" ' + \
'name="optionnotes" style="height:400px">' + \
'name="optionnotes" style="height:400px" spellcheck="true">' + \
personNotes + '</textarea>\n'
optionsStr += ' </form>\n'

View File

@ -1260,12 +1260,12 @@ def htmlEditProfile(cssCache: {}, translate: {}, baseDir: str, path: str,
if instanceDescription:
instanceStr += \
' <textarea id="message" name="instanceDescription" ' + \
'style="height:200px">' + \
'style="height:200px" spellcheck="true">' + \
instanceDescription + '</textarea>'
else:
instanceStr += \
' <textarea id="message" name="instanceDescription" ' + \
'style="height:200px"></textarea>'
'style="height:200px" spellcheck="true"></textarea>'
instanceStr += \
' <label class="labels">' + \
translate['Instance Logo'] + '</label>'
@ -1306,7 +1306,8 @@ def htmlEditProfile(cssCache: {}, translate: {}, baseDir: str, path: str,
moderatorsStr += \
' <textarea id="message" name="moderators" placeholder="' + \
translate['List of moderator nicknames'] + \
'..." style="height:200px">' + moderators + '</textarea>'
'..." style="height:200px" spellcheck="false">' + \
moderators + '</textarea>'
moderatorsStr += '</div>'
editors = ''
@ -1320,7 +1321,8 @@ def htmlEditProfile(cssCache: {}, translate: {}, baseDir: str, path: str,
translate['A list of editor nicknames. One per line.']
editorsStr += \
' <textarea id="message" name="editors" placeholder="" ' + \
'style="height:200px">' + editors + '</textarea>'
'style="height:200px" spellcheck="false">' + \
editors + '</textarea>'
editorsStr += '</div>'
themes = getThemesList(baseDir)
@ -1369,8 +1371,8 @@ def htmlEditProfile(cssCache: {}, translate: {}, baseDir: str, path: str,
peertubeInstancesStr += url + '\n'
peertubeStr += \
' <textarea id="message" name="ptInstances" ' + \
'style="height:200px">' + peertubeInstancesStr + \
'</textarea>\n'
'style="height:200px" spellcheck="false">' + \
peertubeInstancesStr + '</textarea>\n'
instanceTitle = \
getConfigParam(baseDir, 'instanceTitle')
@ -1429,8 +1431,8 @@ def htmlEditProfile(cssCache: {}, translate: {}, baseDir: str, path: str,
editProfileForm += \
' <label class="labels">' + translate['Your bio'] + '</label>\n'
editProfileForm += \
' <textarea id="message" name="bio" style="height:200px">' + \
bioStr + '</textarea>\n'
' <textarea id="message" name="bio" style="height:200px" ' + \
'spellcheck="true">' + bioStr + '</textarea>\n'
alsoKnownAsStr = ''
if actorJson.get('alsoKnownAs'):
@ -1509,7 +1511,8 @@ def htmlEditProfile(cssCache: {}, translate: {}, baseDir: str, path: str,
editProfileForm += \
' <textarea id="message" placeholder=' + \
'"-----BEGIN PGP PUBLIC KEY BLOCK-----" name="pgp" ' + \
'style="height:100px">' + PGPpubKey + '</textarea>\n'
'style="height:100px" spellcheck="false">' + \
PGPpubKey + '</textarea>\n'
editProfileForm += '<a href="/users/' + nickname + \
'/followingaccounts"><label class="labels">' + \
translate['Following'] + '</label></a><br>\n'
@ -1622,7 +1625,7 @@ def htmlEditProfile(cssCache: {}, translate: {}, baseDir: str, path: str,
editProfileForm += ' <br><label class="labels">' + \
translate['One per line'] + '</label>\n'
editProfileForm += ' <textarea id="message" ' + \
'name="filteredWords" style="height:200px">' + \
'name="filteredWords" style="height:200px" spellcheck="false">' + \
filterStr + '</textarea>\n'
editProfileForm += \
@ -1631,7 +1634,8 @@ def htmlEditProfile(cssCache: {}, translate: {}, baseDir: str, path: str,
editProfileForm += ' <br><label class="labels">A -> B</label>\n'
editProfileForm += \
' <textarea id="message" name="switchWords" ' + \
'style="height:200px">' + switchStr + '</textarea>\n'
'style="height:200px" spellcheck="false">' + \
switchStr + '</textarea>\n'
editProfileForm += \
' <br><b><label class="labels">' + \
@ -1639,7 +1643,8 @@ def htmlEditProfile(cssCache: {}, translate: {}, baseDir: str, path: str,
editProfileForm += ' <br><label class="labels">A -> #B</label>\n'
editProfileForm += \
' <textarea id="message" name="autoTags" ' + \
'style="height:200px">' + autoTags + '</textarea>\n'
'style="height:200px" spellcheck="false">' + \
autoTags + '</textarea>\n'
editProfileForm += \
' <br><b><label class="labels">' + \
@ -1647,7 +1652,7 @@ def htmlEditProfile(cssCache: {}, translate: {}, baseDir: str, path: str,
editProfileForm += ' <br><label class="labels">A -> B</label>\n'
editProfileForm += \
' <textarea id="message" name="autoCW" ' + \
'style="height:200px">' + autoCW + '</textarea>\n'
'style="height:200px" spellcheck="true">' + autoCW + '</textarea>\n'
editProfileForm += \
' <br><b><label class="labels">' + \
@ -1657,8 +1662,8 @@ def htmlEditProfile(cssCache: {}, translate: {}, baseDir: str, path: str,
editProfileForm += \
' <br><label class="labels">' + translate[idx] + '</label>\n'
editProfileForm += \
' <textarea id="message" name="blocked" style="height:200px">' + \
blockedStr + '</textarea>\n'
' <textarea id="message" name="blocked" style="height:200px" ' + \
'spellcheck="false">' + blockedStr + '</textarea>\n'
editProfileForm += \
' <br><b><label class="labels">' + \
@ -1670,7 +1675,8 @@ def htmlEditProfile(cssCache: {}, translate: {}, baseDir: str, path: str,
translate[idx] + '</label>\n'
editProfileForm += \
' <textarea id="message" name="allowedInstances" ' + \
'style="height:200px">' + allowedInstancesStr + '</textarea>\n'
'style="height:200px" spellcheck="false">' + \
allowedInstancesStr + '</textarea>\n'
editProfileForm += \
' <br><b><label class="labels">' + \
@ -1681,7 +1687,8 @@ def htmlEditProfile(cssCache: {}, translate: {}, baseDir: str, path: str,
translate[idx] + '</label>\n'
editProfileForm += \
' <textarea id="message" name="gitProjects" ' + \
'style="height:100px">' + gitProjectsStr + '</textarea>\n'
'style="height:100px" spellcheck="false">' + \
gitProjectsStr + '</textarea>\n'
editProfileForm += \
' <br><b><label class="labels">' + \

View File

@ -110,7 +110,8 @@ def htmlWelcomeProfile(baseDir: str, nickname: str, domain: str,
profileForm += ' <label class="labels">' + \
translate['Your bio'] + '</label><br>\n'
profileForm += ' <textarea id="message" name="bio" ' + \
'style="height:130px">' + bioStr + '</textarea>\n'
'style="height:130px" spellcheck="true">' + \
bioStr + '</textarea>\n'
profileForm += '</div>\n'
profileForm += '<div class="container next">\n'