Skip to content

Commit 283aefa

Browse files
s19110myteron
andauthored
Update docs/Secure-Coding-Guide-for-Python/CWE-707/CWE-175/README.md
Co-authored-by: myteron <[email protected]> Signed-off-by: Hubert Daniszewski <[email protected]>
1 parent acea30e commit 283aefa

File tree

1 file changed

+3
-13
lines changed
  • docs/Secure-Coding-Guide-for-Python/CWE-707/CWE-175

1 file changed

+3
-13
lines changed

docs/Secure-Coding-Guide-for-Python/CWE-707/CWE-175/README.md

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -149,30 +149,20 @@ ORIGINAL_NUMBER = 12.345 # This will read as 12,345 in German
149149

150150

151151
def compare_number(number):
152-
input_number = locale.atof(input("Enter a number: "))
152+
input_number = locale.atof(input(f"Enter a number {ORIGINAL_NUMBER}: "))
153153
# Test if inputted number equals current number
154154
return number == input_number
155155

156156

157157
print(f"Locale is {locale.getlocale()}")
158-
print(f"Do the numbers match? {compare_number(ORIGINAL_NUMBER)}")
159-
160-
# Console output:
161-
# Locale is ('English_Ireland', '1252')
162-
# Enter a number: 12,345
163-
# Do the numbers match? False
164158

165-
# After setting the locale
159+
print(f"Do the numbers match? {compare_number(ORIGINAL_NUMBER)}")
166160

161+
# Setting the locale to German
167162
locale.setlocale(locale.LC_ALL, 'de_DE.utf8')
168163
print(f"Locale is {locale.getlocale()}")
169164
print(f"Do the numbers match? {compare_number(ORIGINAL_NUMBER)}")
170165

171-
# Console output:
172-
# Locale is ('de_DE', 'UTF-8')
173-
# Enter a number: 12,345
174-
# Do the numbers match? True
175-
176166
```
177167

178168
## Non-Compliant Code Example (Encoding)

0 commit comments

Comments
 (0)