f-strings vs. format strings #15

Closed
opened 2020-06-06 15:58:06 +00:00 by phryk · 1 comment
phryk commented 2020-06-06 15:58:06 +00:00 (Migrated from rnd.phryk.net)

Get langsec clarity on usage of f-strings (f"foo{bar}") vs format strings ("foo%s" % bar) and adjust any places using the inferior option.

Get langsec clarity on usage of f-strings (`f"foo{bar}"`) vs format strings (`"foo%s" % bar`) and adjust any places using the inferior option.
phryk commented 2020-06-06 16:49:57 +00:00 (Migrated from rnd.phryk.net)

According to GothAlice (tyvm!) format strings/sprintf substitutions are "too inconsistent in use and application". Whoopsie. ¯_(ツ)_/¯

f-strings deemed best option since their base string can't be dynamic.

>>> x = "}{__name__"; f"{x}"
'}{__name__'

↑ Seems to be at least immediately injection resistant in practical test, too.

According to GothAlice (tyvm!) format strings/sprintf substitutions are "too inconsistent in use and application". Whoopsie. ¯\_(ツ)_/¯ f-strings deemed best option since their base string can't be dynamic. ``` >>> x = "}{__name__"; f"{x}" '}{__name__' ``` ↑ Seems to be at least immediately injection resistant in practical test, too.
phryk closed this issue 2021-05-14 19:04:42 +00:00
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: phryk-evil-mad-sciences-llc/poobrains#15
No description provided.