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/
Merge branch 'release-1.7.x' into release-2.0.x
Finish the merge.
Fix unicode problems when processing errors from SVN.

When processing any errors that come out of the pysvn client, we would cast the
exception to unicode without specifying an encoding. This resulted in any utf-8
filenames or other text triggering a UnicodeDecodeError. I've changed this to
first coerce the exception to bytes, and then decode. While I was in here, I
also fixed up a duplicate cast.

Testing done:
Ran unit tests (this error handler is exercised in the tests).

Fixes bug 3518.

Reviewed at https://reviews.reviewboard.org/r/6196/
Merge branch 'release-2.0.x'