Fixed bug causing text to be corrupted when detecting links