An Afghan woman who was jailed for being raped and then told to marry her attacker by a judge has had her sentence overturned by the country’s president.