Moved the check for patterns to the commands/filters

This is because different commands and filters check for patterns in
different ways and because the passthrough code should be centralised.