Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
raise utils.MailmergeError("Empty attachment header.")
# Create a Path object and handle home directory (tilde ~) notation
path = Path(path.strip())
path = path.expanduser()
# Relative paths are relative to the template's parent dir
if not path.is_absolute():
path = self.template_path.parent/path
# Resolve any symlinks
path = path.resolve()
# Check that the attachment exists
if not path.exists():
raise utils.MailmergeError("Attachment not found: {}".format(path))
return path
def _resolve_attachment_path(self, path):
"""Find attachment file or raise MailmergeError."""
# Error on empty path
if not path.strip():
raise utils.MailmergeError("Empty attachment header.")
# Create a Path object and handle home directory (tilde ~) notation
path = Path(path.strip())
path = path.expanduser()
# Relative paths are relative to the template's parent dir
if not path.is_absolute():
path = self.template_path.parent/path
# Resolve any symlinks
path = path.resolve()
# Check that the attachment exists
if not path.exists():
raise utils.MailmergeError("Attachment not found: {}".format(path))