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:
parent
7496569ccf
commit
1924e33ef5
1 changed files with 8 additions and 0 deletions
|
@ -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:
|
||||
|
|
Loading…
Reference in a new issue