Original fix by 'rep', final patch (with tests) by Xuanji Li.
Attach a file by drag & drop or click to upload