Greetings dev,
It certainly is illegal to sell an account with your character attached,
what it actually means when you come across users selling "whole characters" in a trade post is that they were actually selling all the gear and the inventory of their character but not the actual character and account itself.
Feel free to PM me if you have more questions in-regards to this matter.