Fixed extension checking

One last commit before stopping bothering you :)
The extension checking mechanism is bugged: it doesn't check correctly for substrings and assumes the string to be zero-terminated which is not (if the last extension in the string is checked an out of bounds exception is triggered).