From 21573b6ca7fa0ea3df84b0f0883c1fea90711b9b Mon Sep 17 00:00:00 2001
From: Bob Mottram ', '')
+ contentLines = contentStr.split(' ' + lineStr + ' ' + lineStr + '')
+ newContent += '
hello@@ -612,6 +631,7 @@ def addHtmlTags(baseDir: str, httpPrefix: str, by matching against known following accounts """ if content.startswith('
'): + content = htmlReplaceEmailQuote(content) return htmlReplaceQuoteMarks(content) maxWordLength = 40 content = content.replace('\r', '') @@ -718,6 +738,7 @@ def addHtmlTags(baseDir: str, httpPrefix: str, if longWordsList: content = removeLongWords(content, maxWordLength, longWordsList) content = content.replace(' --linebreak-- ', '
') + content = htmlReplaceEmailQuote(content) return '
' + htmlReplaceQuoteMarks(content) + '
' diff --git a/tests.py b/tests.py index 51b00cbd4..ecb58134a 100644 --- a/tests.py +++ b/tests.py @@ -68,6 +68,7 @@ from delete import sendDeleteViaServer from inbox import jsonPostAllowsComments from inbox import validInbox from inbox import validInboxFilenames +from content import htmlReplaceEmailQuote from content import htmlReplaceQuoteMarks from content import dangerousMarkup from content import removeHtml @@ -2124,8 +2125,33 @@ def testConstantTimeStringCheck(): assert timeDiffMicroseconds < 10 +def testReplaceEmailQuote(): + print('testReplaceEmailQuote') + testStr='This content has no quote.
' + assert htmlReplaceEmailQuote(testStr) == testStr + + testStr='This content has no quote.\nWith multiple\nlines
' + assert htmlReplaceEmailQuote(testStr) == testStr + + testStr = "" + \
+ "@nickname " + \
+ "
> This is a quote
Some other text.
" + expectedStr = "" + \
+ "@nickname " + \
+ "
This is a quote" + \ + "
Some other text.
" + resultStr = htmlReplaceEmailQuote(testStr) + if resultStr != expectedStr: + print('Result: ' + resultStr) + print('Expect: ' + expectedStr) + assert resultStr == expectedStr + + def runAllTests(): print('Running tests...') + testReplaceEmailQuote() testConstantTimeStringCheck() testTranslations() testValidContentWarning()