Issue #181: Backports for SA-CORE-2013-001.

PR for https://github.com/backdrop/backdrop-issues/issues/181, which includes backports of security fixes present in Drupal 7.19.