Download tasks/codeql_python_benchmark51_v2/pyvul-98fc634e79976d5b5241/patch.diff from Benchanything/checkerbench: direct link, hf CLI and curl.
- Browser
- Download file 1.93 kB
-
https://huggingface.co/datasets/Benchanything/checkerbench/resolve/main/tasks/codeql_python_benchmark51_v2/pyvul-98fc634e79976d5b5241/patch.diff
- Command line
-
hf download hf://datasets/Benchanything/checkerbench/tasks/codeql_python_benchmark51_v2/pyvul-98fc634e79976d5b5241/patch.diff
-
curl -L -o patch.diff https://huggingface.co/datasets/Benchanything/checkerbench/resolve/main/tasks/codeql_python_benchmark51_v2/pyvul-98fc634e79976d5b5241/patch.diff
1.93 kB
| diff --git a/sydent/util/emailutils.py b/sydent/util/emailutils.py | |
| index 2ae5fdc..7b3b92c 100644 | |
| --- a/sydent/util/emailutils.py | |
| +++ b/sydent/util/emailutils.py | |
| def sendEmail(sydent, templateName, mailTo, substitutions): | |
| allSubstitutions[k+"_forhtml"] = cgi.escape(v.decode('utf8')) | |
| allSubstitutions[k+"_forurl"] = urllib.quote(v) | |
| - mailString = open(mailTemplateFile).read() % allSubstitutions | |
| - rawFrom = email.utils.parseaddr(mailFrom)[1] | |
| - rawTo = email.utils.parseaddr(mailTo)[1] | |
| - if rawFrom == '' or rawTo == '': | |
| + mailString = open(mailTemplateFile).read().decode('utf8') % allSubstitutions | |
| + parsedFrom = email.utils.parseaddr(mailFrom)[1] | |
| + parsedTo = email.utils.parseaddr(mailTo)[1] | |
| + if parsedFrom == '' or parsedTo == '': | |
| logger.info("Couldn't parse from / to address %s / %s", mailFrom, mailTo) | |
| raise EmailAddressException() | |
| + | |
| mailServer = sydent.cfg.get('email', 'email.smtphost') | |
| mailPort = sydent.cfg.get('email', 'email.smtpport') | |
| mailUsername = sydent.cfg.get('email', 'email.smtpusername') | |
| def sendEmail(sydent, templateName, mailTo, substitutions): | |
| smtp = smtplib.SMTP(mailServer, mailPort, myHostname) | |
| if mailUsername != '': | |
| smtp.login(mailUsername, mailPassword) | |
| - smtp.sendmail(rawFrom, rawTo, mailString.encode('utf-8')) | |
| + | |
| + # We're using the parsing above to do basic validation, but instead of | |
| + # failing it may munge the address it returns. So we should *not* use | |
| + # that parsed address, as it may not match any validation done | |
| + # elsewhere. | |
| + smtp.sendmail(mailFrom, mailTo, mailString.encode('utf-8')) | |
| smtp.quit() | |
| except Exception as origException: | |
| twisted.python.log.err() | |