Skip to content

Commit ef78c07

Browse files
engelkeleahecole
authored andcommitted
fix: unsanitized output (#8316)
* fix: unsanitized output * fix: add license to template
1 parent 0ba0578 commit ef78c07

File tree

2 files changed

+31
-7
lines changed

2 files changed

+31
-7
lines changed

appengine/standard_python3/cloud_debugger/main.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
# [START gae_python3_app]
1717
import logging
1818

19-
from flask import Flask, request
19+
from flask import Flask, render_template, request
2020

2121
# Enable cloud debugger
2222
try:
@@ -67,12 +67,7 @@ def ReverseString():
6767

6868
current = StringProcessor(s).Reverse()
6969
expected = s[::-1]
70-
return '''
71-
<table>
72-
<tr><th>Program Output:</th><th>{}</th></tr>
73-
<tr><th>Correct Output:</th><th>{}</th><tr>
74-
</table>
75-
'''.format(current, expected)
70+
return render_template("index.html", current=current, expected=expected)
7671

7772

7873
@app.route('/')
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<!DOCTYPE html>
2+
<!--
3+
Copyright 2022 Google LLC
4+
5+
Licensed under the Apache License, Version 2.0 (the "License");
6+
you may not use this file except in compliance with the License.
7+
You may obtain a copy of the License at
8+
9+
http://www.apache.org/licenses/LICENSE-2.0
10+
11+
Unless required by applicable law or agreed to in writing, software
12+
distributed under the License is distributed on an "AS IS" BASIS,
13+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
See the License for the specific language governing permissions and
15+
limitations under the License.
16+
-->
17+
18+
<html>
19+
<head>
20+
<title>Reverse a String</title>
21+
</head>
22+
23+
<body>
24+
<table>
25+
<tr><th>Program Output:</th><th>{{ current }}</th></tr>
26+
<tr><th>Correct Output:</th><th>{{ expected }}</th><tr>
27+
</table>
28+
</body>
29+
</html>

0 commit comments

Comments
 (0)