diff --git a/editorconfig/fnmatch.py b/editorconfig/fnmatch.py index 1a7880b..53557ef 100644 --- a/editorconfig/fnmatch.py +++ b/editorconfig/fnmatch.py @@ -135,7 +135,7 @@ def translate(pat, nested=False): else: result += '[^/]*' elif current_char == '?': - result += '.' + result += '[^/]' elif current_char == '[': if in_brackets: result += '\\[' @@ -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 @@ -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 diff --git a/editorconfig/ini.py b/editorconfig/ini.py index 92ffb13..c603d79 100644 --- a/editorconfig/ini.py +++ b/editorconfig/ini.py @@ -27,6 +27,10 @@ __all__ = ["ParsingError", "EditorConfigParser"] +MAX_SECTION_LENGTH = 4096 +MAX_PROPERTY_LENGTH= 50 +MAX_VALUE_LENGTH = 255 + class EditorConfigParser(object): @@ -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 @@ -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: diff --git a/tests b/tests index abb579e..db8833f 160000 --- a/tests +++ b/tests @@ -1 +1 @@ -Subproject commit abb579e00f2deeede91cb485e53512efab9c6474 +Subproject commit db8833f0623b64c56844ae3cd7aa3f8c961e6edc