Skip to content

Commit

Permalink
tests: bump to master (#32)
Browse files Browse the repository at this point in the history
  • Loading branch information
greut authored Dec 7, 2020
1 parent 404d7c0 commit b107472
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
13 changes: 8 additions & 5 deletions editorconfig/fnmatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def translate(pat, nested=False):
else:
result += '[^/]*'
elif current_char == '?':
result += '.'
result += '[^/]'
elif current_char == '[':
if in_brackets:
result += '\\['
Expand All @@ -148,8 +148,8 @@ def translate(pat, nested=False):
break
pos += 1
if has_slash:
result += '\\[' + pat[index:(pos + 1)] + '\\]'
index = pos + 2
result += '\\[' + pat[index:(pos + 1)]
index = pos + 1
else:
if index < length and pat[index] in '!^':
index += 1
Expand All @@ -163,8 +163,11 @@ def translate(pat, nested=False):
else:
result += '\\' + current_char
elif current_char == ']':
result += current_char
in_brackets = False
if in_brackets and pat[index-2] == '\\':
result += '\\]'
else:
result += current_char
in_brackets = False
elif current_char == '{':
pos = index
has_comma = False
Expand Down
9 changes: 9 additions & 0 deletions editorconfig/ini.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@

__all__ = ["ParsingError", "EditorConfigParser"]

MAX_SECTION_LENGTH = 4096
MAX_PROPERTY_LENGTH= 50
MAX_VALUE_LENGTH = 255


class EditorConfigParser(object):

Expand Down Expand Up @@ -134,6 +138,8 @@ def _read(self, fp, fpname):
mo = self.SECTCRE.match(line)
if mo:
sectname = mo.group('header')
if len(sectname) > MAX_SECTION_LENGTH:
continue
in_section = True
matching_section = self.matches_filename(fpname, sectname)
# So sections can't start with a continuation line
Expand All @@ -154,6 +160,9 @@ def _read(self, fp, fpname):
if optval == '""':
optval = ''
optname = self.optionxform(optname.rstrip())
if (len(optname) > MAX_PROPERTY_LENGTH or
len(optval) > MAX_VALUE_LENGTH):
continue
if not in_section and optname == 'root':
self.root_file = (optval.lower() == 'true')
if matching_section:
Expand Down

0 comments on commit b107472

Please sign in to comment.