1
0
Fork 0
mirror of https://github.com/borgbackup/borg.git synced 2025-02-22 14:11:27 +00:00

format_line: deny access to internal objects

This commit is contained in:
Marian Beermann 2017-04-04 23:59:58 +02:00
parent 7496569ccf
commit 1924e33ef5

View file

@ -110,6 +110,10 @@ class PlaceholderError(Error):
"""Formatting Error: "{}".format({}): {}({})"""
class InvalidPlaceholder(PlaceholderError):
"""Invalid placeholder "{}" in string: {}"""
def check_extension_modules():
from . import platform, compress, item
if hashindex.API_VERSION != '1.1_01':
@ -780,6 +784,10 @@ def __format__(self, format_spec):
def format_line(format, data):
keys = [f[1] for f in Formatter().parse(format)]
for key in keys:
if '.' in key or '__' in key:
raise InvalidPlaceholder(key, format)
try:
return format.format(**data)
except Exception as e: