Compile template and restrict globals for eval
This commit is contained in:
parent
d6ddfa9d18
commit
8bb8615a5a
@ -54,14 +54,18 @@ def draw_title(draw_data: DrawData, screen: Screen, tab: TabBarData, index: int)
|
||||
screen.cursor.fg = draw_data.bell_fg
|
||||
screen.draw('🔔 ')
|
||||
screen.cursor.fg = fg
|
||||
layout_name = tab.layout_name
|
||||
num_windows = tab.num_windows
|
||||
template = draw_data.title_template
|
||||
title = tab.title
|
||||
if tab.is_active and draw_data.active_title_template is not None:
|
||||
template = draw_data.active_title_template
|
||||
try:
|
||||
title = eval(f"f'{template}'")
|
||||
eval_locals = {
|
||||
'index': index,
|
||||
'layout_name': tab.layout_name,
|
||||
'num_windows': tab.num_windows,
|
||||
'title': tab.title
|
||||
}
|
||||
compiled_template = compile('f"""' + template + '"""', '<tab_template>', 'eval')
|
||||
title = eval(compiled_template, {'__builtins__': {}}, eval_locals)
|
||||
except Exception as e:
|
||||
if template not in template_failures:
|
||||
template_failures.add(template)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user