For reference, this is the fix implemented by the WordPress team:

http://trac.wordpress.org/changeset/4717