Browse files

Fix that a regular expression can be configured with a lenght.

I started adding matching movie files (mp4) etc and those are huge, so I dont want them in the memory :)
  • Loading branch information...
1 parent a2d6255 commit bbcd4e04f0d9cb0e60ad7ec98c40383d39e024d3 @tuxBurner tuxBurner committed May 15, 2012
Showing with 4 additions and 1 deletion.
  1. +4 −1 src/main/java/net/sf/jmimemagic/MagicMatcher.java
View
5 src/main/java/net/sf/jmimemagic/MagicMatcher.java
@@ -186,7 +186,10 @@ public MagicMatch test(File f, boolean onlyMimeMatch)
} else if (type.equals("string")) {
length = match.getTest().capacity();
} else if (type.equals("regex")) {
- length = (int) file.length() - offset;
+
+
+ final int matchLength = match.getLength();
+ length = (matchLength == 0) ? (int) file.length() - offset : matchLength;
if (length < 0) {
length = 0;

0 comments on commit bbcd4e0

Please sign in to comment.