diff --git a/main.py b/main.py index dd60721..839fe1d 100755 --- a/main.py +++ b/main.py @@ -123,7 +123,10 @@ def submission (): subject = re.sub(form_regex, r'{\1}', form['subject']).format(**subject_fields) content = re.sub(form_regex, r'{\1}', form['content']).format(**content_fields) + print(subject) + print(content) + return 'aborted' try: if not send_mail(from_address, form['mail'], subject, content): response.status = 500 @@ -142,14 +145,14 @@ def get_fields (string): """ Parse the string looking for template elements and create an array with template to fill and their default values. None if mandatory. """ result = {} for match in re.findall(form_regex, string): - result[match[0]] = match[1] + result[match[0]] = None if match[1] == '' else match[1][1:] return result def fill_fields(request, fields): """Look for fields in request and fill fields dict with values or let default ones. If the value is required, throw exception.""" for field in fields: if field in request.forms: - fields[field] = html.escape(request.forms[field]) + fields[field] = request.forms.getunicode(field) elif fields[field] == None: raise MissingParameterException("Le champs {} est obligatoire".format(field)) return fields diff --git a/readme.md b/readme.md index 57bcd10..0a1951f 100644 --- a/readme.md +++ b/readme.md @@ -74,6 +74,7 @@ You can store them in a `.env` file. The python app will read it or you can pass - [unit tests](https://bottlepy.org/docs/dev/recipes.html#unit-testing-bottle-applications) - add redirection urls to form config - Include some [capcha](https://alternativeto.net/software/recaptcha/) support +- Correctly escape html entities ### Ameliorations - Use real user/passwords accounts