Most Islamic countries regard homosexuality as morally unacceptable, and a crime. But gay activists say homophobia is a Western import, and documents show that centuries ago, Arab leaders were much more liberal when it came to sex. The Economist’s Middle East correspondent Nicholas Pelham explains.