I have just noticed that Google as well as some other sites trims the whitespaces in the password.

I can successfully sign into my google account even if I add extra spaces in the end of my password.

Is this behaviour intended or a bug?

I also tried some other sites, and I found out that many sites do such things.

I believe this is a very serious security issue, as some people may intentionally add spaces at the beginning or the end of the password to enhance the security.