diff --git a/core/src/main/java/org/ec4j/core/model/Glob.java b/core/src/main/java/org/ec4j/core/model/Glob.java index 0e7c091..9175208 100644 --- a/core/src/main/java/org/ec4j/core/model/Glob.java +++ b/core/src/main/java/org/ec4j/core/model/Glob.java @@ -47,7 +47,6 @@ */ public class Glob { - private static final int MAX_GLOB_LENGTH = 4096; private final PatternSyntaxException error; private final List ranges; private final Pattern regex; @@ -58,32 +57,24 @@ public class Glob { public Glob(String source) { this.source = source; this.ranges = new ArrayList(); - if (source.length() > MAX_GLOB_LENGTH) { - this.regex = null; - this.error = new PatternSyntaxException( - "Glob length exceeds the maximal allowed length of " + MAX_GLOB_LENGTH + " characters", source, - MAX_GLOB_LENGTH); - this.matchLastSegmentOnly = false; - } else { - source = ESCAPED_COMMENT_SIGNS.matcher(source).replaceAll("$1"); - final int slashPos = source.indexOf('/'); - final int doubleAsteriskPos = source.indexOf("**"); - if (slashPos >= 0) { - source = (slashPos == 0 ? source.substring(1) : source); - } - this.matchLastSegmentOnly = slashPos < 0 && doubleAsteriskPos < 0; - final StringBuilder regex = new StringBuilder(source.length()); - convertGlobToRegEx(source, ranges, regex); - PatternSyntaxException err = null; - Pattern pat = null; - try { - pat = Pattern.compile(regex.toString()); - } catch (PatternSyntaxException e) { - err = e; - } - this.error = err; - this.regex = pat; + source = ESCAPED_COMMENT_SIGNS.matcher(source).replaceAll("$1"); + final int slashPos = source.indexOf('/'); + final int doubleAsteriskPos = source.indexOf("**"); + if (slashPos >= 0) { + source = (slashPos == 0 ? source.substring(1) : source); + } + this.matchLastSegmentOnly = slashPos < 0 && doubleAsteriskPos < 0; + final StringBuilder regex = new StringBuilder(source.length()); + convertGlobToRegEx(source, ranges, regex); + PatternSyntaxException err = null; + Pattern pat = null; + try { + pat = Pattern.compile(regex.toString()); + } catch (PatternSyntaxException e) { + err = e; } + this.error = err; + this.regex = pat; } @Override diff --git a/core/src/main/java/org/ec4j/core/model/Property.java b/core/src/main/java/org/ec4j/core/model/Property.java index ba95f67..8410ac6 100644 --- a/core/src/main/java/org/ec4j/core/model/Property.java +++ b/core/src/main/java/org/ec4j/core/model/Property.java @@ -50,16 +50,6 @@ public Property build() { return new Property(sealAdapters(), type, name, value); } - boolean checkMax() { - if (name != null && name.length() > 50) { - return false; - } - if (value != null && value.getSource().length() > 255) { - return false; - } - return true; - } - /** * Adds this {@link Builder} to the parent {@link Section.Builder} using parent * {@link Section.Builder#property(Property.Builder)} and returns the parent {@link Section.Builder} @@ -67,10 +57,7 @@ boolean checkMax() { * @return the parent {@link Section.Builder} */ public Section.Builder closeProperty() { - if (checkMax()) { - parentBuilder.property(this); - } - return parentBuilder; + return parentBuilder.property(this); } /** diff --git a/core/src/test/java/org/ec4j/core/EditorConfigParserTest.java b/core/src/test/java/org/ec4j/core/EditorConfigParserTest.java index c0f1177..c6c8ccb 100644 --- a/core/src/test/java/org/ec4j/core/EditorConfigParserTest.java +++ b/core/src/test/java/org/ec4j/core/EditorConfigParserTest.java @@ -246,7 +246,7 @@ public void max_section_name_ok() throws IOException { } @Test - public void max_section_name_ignore() throws IOException { + public void max_section_name_long() throws IOException { final String testFile = "root/test4"; StringResourceTree tree = StringResourceTree.builder() // .resource("root/.editorconfig", getClass().getResource("/parser/.editorconfig"), StandardCharsets.UTF_8)// @@ -255,7 +255,9 @@ public void max_section_name_ignore() throws IOException { Collection properties = ResourcePropertiesService.default_() .queryProperties(tree.getResource(testFile)).getProperties().values(); - Assert.assertEquals(0, properties.size()); + Assert.assertEquals(1, properties.size()); + Iterator it = properties.iterator(); + Assert.assertEquals("key4 = value4", it.next().toString()); } @Test