Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This will work for "simple" things only because we're using a different regex engine.
But out of the 36 regular expressions, only the one for
application/x-dbffails.However, due to uncertainties in their real-world handling and possible regex warnings, I introduced a
well_known_regex_typesvariable where we have fixtures available in the repo and they're actively tested in the build.For the moment, regex handling is activated for
application/x-bzip2andtext/htmlonly.Therefore we can get rid of that
text/htmldefinition inlib/marcel/mime_type/definitions.rbnow. 🎉Furthermore I hoped that this would also make PR #130 obsolete, because
looked pretty decent at first but a JS string with
html='<html><h1>';will still trick it, right? 🤔As the cherry on top, this PR removes the buggy and unhandled entries in the
MAGICconstant because the regular expressions (as well as any other unsupported types) were unfortunately always handled as binary data.We wrote a warning (
warn "#{mime['type']}: unsupported #{type} match: #{match.to_s}") during generation, but we still returned the string, resulting in wrong rules and unnecessary entries inMIME. 😉Hence we had rules like the following
Its content doesn't make any sense if it's not treated as a regular expression and they will hopefully never match anyway, yet they were just wasting a bit of computation and memory.
Now I am much happier with how the PR looks like. 🙂
EDIT: So this is actually more complicated. In-between I had some failing runs on TruffleRuby and JRuby.
EDIT2: Okay, it looks like everything is running now on all the platforms. What a ride! 😆 🎉
/CC @tomhughes
PS: I'm looking for a new adventure in case anybody is looking to hire or work with a Ruby/Rails/Crystal dev