Skip to content

Commit e482ff5

Browse files
committed
feat: moved html escape from pre database to post database
Information that is in the database can be used in multiple different location: omm, html, javascript. ATM we escape html that is escape in the OMM too but does not have to be escaped here. It is better to save raw values in the database and do the proper escaping when the data is needed.
1 parent 47a78ec commit e482ff5

3 files changed

Lines changed: 12 additions & 12 deletions

File tree

services/dect-wip/app.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -229,10 +229,10 @@ def CreateUserExtension():
229229
req_json = request.get_json()
230230
ext = UserExtension()
231231

232-
ext.extension = html.escape(req_json['extension'])
232+
ext.extension = req_json['extension']
233233
ext.password = utilities.getRandomNumber(20)
234-
ext.name = html.escape(req_json['name'])
235-
ext.info = html.escape(req_json['info'])
234+
ext.name = req_json['name']
235+
ext.info = req_json['info']
236236
ext.public = bool(req_json['public'])
237237
ext.token = f'{token_prefix}{utilities.getRandomNumber(token_random_count)}'
238238
ext.user_id = current_user.id

services/dect-wip/templates/myextensions.html.j2

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,13 @@
4747

4848
{% for ext in exts %}
4949
<tr>
50-
<td>{{ext.name}}</td>
51-
<td>{{ext.extension}}</td>
52-
<td>{{ext.token | format_token}}</td>
53-
<td>{{ext.password}}</td>
54-
<td>{{ext.info}}</td>
50+
<td>{{ ext.name | e }}</td>
51+
<td>{{ ext.extension | e }}</td>
52+
<td>{{ ext.token | e | format_token }}</td>
53+
<td>{{ ext.password | e }}</td>
54+
<td>{{ ext.info | e }}</td>
5555
<td>
56-
<button type="submit" class="btn btn-danger" onclick="delEntry('{{ext.extension}}')">
56+
<button type="submit" class="btn btn-danger" onclick="delEntry('{{ ext.extension | e }}')">
5757
<i class="bi bi-trash"></i>
5858
</button>
5959
</td>

services/dect-wip/templates/phonebook.html.j2

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@
3333

3434
{% for ext in exts %}
3535
<tr>
36-
<td>{{ext.extension}}</td>
37-
<td>{{ext.name}}</td>
38-
<td>{{ext.info}}</td>
36+
<td>{{ ext.extension | e }}</td>
37+
<td>{{ ext.name | e }}</td>
38+
<td>{{ ext.info | e }}</td>
3939
</tr>
4040
{% endfor %}
4141

0 commit comments

Comments
 (0)