Skip to content

Commit

Permalink
↪️ Merge pull request #143 from Yelp/fix_unicode_in_ini_scan
Browse files Browse the repository at this point in the history
Fix unicode on RHS in ini scan
  • Loading branch information
KevinHock committed Mar 20, 2019
2 parents 1afb05f + 9b26733 commit 6d0ee12
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
7 changes: 5 additions & 2 deletions detect_secrets/plugins/common/ini_file_parser.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import unicode_literals

import configparser
import re

Expand All @@ -20,7 +22,8 @@ def __init__(self, file, add_header=False, exclude_lines_regex=None):
try:
# python2.7 compatible
self.parser.optionxform = unicode
except NameError:
except NameError: # pragma: no cover
# python3 compatible
self.parser.optionxform = str

self.exclude_lines_regex = exclude_lines_regex
Expand All @@ -34,7 +37,7 @@ def __init__(self, file, add_header=False, exclude_lines_regex=None):
try:
# python2.7 compatible
self.parser.read_string(unicode(content))
except NameError:
except NameError: # pragma: no cover
# python3 compatible
self.parser.read_string(content)

Expand Down
3 changes: 3 additions & 0 deletions test_data/config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,6 @@ keyB = 456789123
keyC =

password = 12345678901234 # pragma: whitelist secret

# unicode
foo=bår

0 comments on commit 6d0ee12

Please sign in to comment.