CalDAV/CardDAV account settings user input is not sufficiently sanitized

REPRODUCIBILITY: 100%
OS VERSION: 5.0.0.67
HARDWARE: Xperia X10 II
UI LANGUAGE: En UK
REGRESSION: probably not

DESCRIPTION:

If I enter a custom address book path with a trailing newline, that newline is made part of that path. That makes CardDAV not work.

PRECONDITIONS:

A “CalDAV and CardDAV” account

STEPS TO REPRODUCE:

  1. Create or modify a CalDAV and CardDAV account
  2. Copy text from e.g. a file with a very-long-press of the text, which includes the final newline in the selection.
  3. Paste this in Advanced settings => Custom address book path

EXPECTED RESULT:

Easy-to-miss extraneous characters are stripped from front and back of user input => address book is synced.

ACTUAL RESULT:

A stray newline gets html-encoded into the request to the server, which produces a 404

I suspect this would happen in other places/accounts/fields too.