Skip to content

Commit 8dc3de8

Browse files
committed
TR updates, first round
1 parent 2e1c138 commit 8dc3de8

File tree

7 files changed

+15
-91
lines changed

7 files changed

+15
-91
lines changed

python-t-strings/emails.py

Lines changed: 0 additions & 23 deletions
This file was deleted.

python-t-strings/i18n.py

Lines changed: 0 additions & 25 deletions
This file was deleted.

python-t-strings/logging_message.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
import json
22
import logging
3+
from string.templatelib import Template
34

45
logging.basicConfig(level=logging.INFO, format="%(message)s")
56

67

78
class TemplateMessage:
89
def __init__(self, template):
10+
if not isinstance(template, Template):
11+
raise TypeError("t-string expected")
912
self.template = template
1013

1114
@property

python-t-strings/scape_html.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
import html
2+
from string.templatelib import Template
23

34

4-
def render_safe_html(template):
5+
def generate_safe_html(template):
6+
if not isinstance(template, Template):
7+
raise TypeError("t-string expected")
58
parts = []
69
for item in template:
710
if isinstance(item, str):

python-t-strings/sql.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1+
from string.templatelib import Template
2+
3+
14
def sanitized_sql(template):
5+
if not isinstance(template, Template):
6+
raise TypeError("t-string expected")
27
parts = []
38
params = []
49

@@ -14,7 +19,9 @@ def sanitized_sql(template):
1419

1520

1621
# Uncomment in Python 3.14+
17-
# template = t"SELECT * FROM students WHERE name = '{username}';"
22+
# username = "john'); DROP TABLE students;--"
23+
# template = t"SELECT * FROM students WHERE name = {username}"
1824
# query, params = sanitized_sql(template)
1925
# print("Sanitized SQL Query:", query)
26+
2027
# print("Parameters:", params)

python-t-strings/template_to_string.py

Lines changed: 0 additions & 18 deletions
This file was deleted.

python-t-strings/traverse_items.py

Lines changed: 0 additions & 23 deletions
This file was deleted.

0 commit comments

Comments
 (0)