Skip to content
This repository
Browse code

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...
commit bbcd4e04f0d9cb0e60ad7ec98c40383d39e024d3 1 parent a2d6255
Seppel Hardt tuxBurner authored

Showing 1 changed file with 4 additions and 1 deletion. Show diff stats Hide diff stats

  1. +4 1 src/main/java/net/sf/jmimemagic/MagicMatcher.java
5 src/main/java/net/sf/jmimemagic/MagicMatcher.java
@@ -186,7 +186,10 @@ public MagicMatch test(File f, boolean onlyMimeMatch)
186 186 } else if (type.equals("string")) {
187 187 length = match.getTest().capacity();
188 188 } else if (type.equals("regex")) {
189   - length = (int) file.length() - offset;
  189 +
  190 +
  191 + final int matchLength = match.getLength();
  192 + length = (matchLength == 0) ? (int) file.length() - offset : matchLength;
190 193
191 194 if (length < 0) {
192 195 length = 0;

0 comments on commit bbcd4e0

Please sign in to comment.
Something went wrong with that request. Please try again.