1. Using bitcoin-qt one can enter password with spaces in the window to decrypt the wallet. How to do it with bitcoin-cli? Imagine a password is 120 130 140 (two spaces between the numbers), if I type walletpassphrase 120 130 140 150 will bitcoin-cli interpret 120 130 140 as password (with two spaces) and 150 as timeout?
No, that will not work. You have to surround your passphrase with quotes, so like
walletpassphrase "120 130 140" 150
2. What if spaces are at the beginning and the end of password? How to send such phrase using bitcoin-cli (in GUI when typing spaces arrows appear, so I think GUI normally "sees" those spaces). Thanks!
Again, use double quotes around your entire passphrase.