Guess a file attachment's content type if application/octet-stream.

If a browser claims a file's content type is application/octet-stream,
get a second opinion by asking `file --mime-type`. This helps with some
browsers or server setups where that useless mimetype is being used,
preventing some files from being reviewable.

Fixes bug #2269
Reviewed at https://reviews.reviewboard.org/r/6016/
Don't trust the browser-provided mimetype if it looks bogus.

A user was reporting that their PDF file uploads were being assigned the
mimetype of "text/text/application/pdf", which is completely bogus. If
splitting on '/' produces anything other than a list of two strings, don't
allow it to proceed.

Testing done: Ran unit tests.

Fixes bug 3427.

Reviewed at https://reviews.reviewboard.org/r/6118/
Make SVN keyword handling case-insensitive.

Our existing handling for SVN keywords only works when the keywords had very
specific casing. This change fixes it to lower-case everything first, and does
a case-insensitive regex substitution.

Testing done:
Tested with several diffs that used svn:keywords with various casing.

Reviewed at https://reviews.reviewboard.org/r/6199/
Fix compatibility with Python < 2.7

My change for handling alternate casing in svn:keywords only worked with Python
2.7 (prior versions don't have a `flags` argument to `re.sub()`).

This change makes it so we compile the regex first using re.IGNORECASE, and
then call the substitution method on the regex object.

Testing done: Ran tests under python 2.6

Reviewed at https://reviews.reviewboard.org/r/6207/