Ensure that line endings are removed from changed password

merge-requests/30/head
Bob Mottram 2021-07-20 15:39:43 +01:00
parent 882774bc50
commit 1544e526c4
2 changed files with 13 additions and 0 deletions

View File

@ -210,6 +210,7 @@ from shares import expireShares
from categories import setHashtagCategory from categories import setHashtagCategory
from languages import getActorLanguages from languages import getActorLanguages
from languages import setActorLanguages from languages import setActorLanguages
from utils import removeLineEndings
from utils import getBaseContentFromPost from utils import getBaseContentFromPost
from utils import acctDir from utils import acctDir
from utils import getImageExtensionFromMimeType from utils import getImageExtensionFromMimeType
@ -4237,6 +4238,10 @@ class PubServer(BaseHTTPRequestHandler):
# change password # change password
if fields.get('password') and \ if fields.get('password') and \
fields.get('passwordconfirm'): fields.get('passwordconfirm'):
fields['password'] = \
removeLineEndings(fields['password'])
fields['passwordconfirm'] = \
removeLineEndings(fields['passwordconfirm'])
if len(fields['password']) > 2 and \ if len(fields['password']) > 2 and \
fields['password'] == fields['passwordconfirm']: fields['password'] == fields['passwordconfirm']:
# set password # set password

View File

@ -2606,3 +2606,11 @@ def validUrlPrefix(url: str) -> bool:
if url.startswith(pre): if url.startswith(pre):
return True return True
return False return False
def removeLineEndings(text: str) -> str:
"""Removes any newline from the end of a string
"""
text = text.replace('\n', '')
text = text.replace('\r', '')
return text.strip()