Skip to content

Commit 8cb32a4

Browse files
committed
Prevent HTML injection errors
Resolves #42
1 parent cd25b19 commit 8cb32a4

1 file changed

Lines changed: 14 additions & 9 deletions

File tree

menus.py

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -352,10 +352,15 @@ def _get_token(self):
352352

353353
time.sleep(2)
354354
self.waiting_layout.children = [
355-
Window(FormattedTextControl(HTML(
356-
'\n\n\n\n\n<b>Done!</b>\n\n'
357-
f'Signed in as <b>{self.app.user.username}#{self.app.user.discriminator}</b>.\n\n'
358-
)), align=WindowAlign.CENTER, wrap_lines=False)
355+
Window(
356+
FormattedTextControl(
357+
HTML(
358+
'\n\n\n\n\n<b>Done!</b>\n\n'
359+
'Signed in as <b>{}#{}</b>.\n\n'
360+
).format(self.app.user.username, self.app.user.discriminator)
361+
),
362+
align=WindowAlign.CENTER, wrap_lines=False
363+
)
359364
]
360365
self.update()
361366

@@ -446,10 +451,10 @@ def get_layout(self):
446451
console: str = console_and_game_id[0]
447452
game_id: str = console_and_game_id[1]
448453

449-
label_text = f'<b>-</b> {game_id} ({console.title()})'
454+
label_text = HTML('<b>-</b> {} ({})').format(game_id, console.title())
450455
else:
451-
label_text = f'<b>-</b> {console_and_game_id[0]}'
452-
game_labels.append(Label(HTML(label_text)))
456+
label_text = HTML('<b>-</b> {}').format(console_and_game_id[0])
457+
game_labels.append(Label(label_text))
453458

454459
right_panel_layout = HSplit([])
455460
if self.right_panel_state == 'Menu':
@@ -467,8 +472,8 @@ def get_layout(self):
467472
Frame(
468473
Box(
469474
HSplit([
470-
Label(HTML(f'<b>Name:</b> {self.riitag_info.name}')),
471-
Label(HTML(f'<b>Games:</b> {len(game_labels)}')),
475+
Label(HTML('<b>Name:</b> {}').format(self.riitag_info.name)),
476+
Label(HTML('<b>Games:</b> {}').format(len(game_labels))),
472477
*game_labels
473478
]), padding_left=3, padding_top=2
474479
), title='RiiTag'),

0 commit comments

Comments
 (0)