Patch from Dieter Maurer, with tests sponsored by a bounty from Logicalware.
Attach a file by drag & drop or click to upload