__vte_prompt_command doesn't escape control characters in $PWD
__vte_prompt_command sets the window title with OSC 0 to a string that includes the current working directory. However, $PWD can includes control characters that end the OSC sequence, such as BEL and ESC (in fact, I'm pretty sure those are the only ones). Those characters should be stripped or encoded.
mkdir $'test\adir' and
cd into it. The window title stops at the end of
dir is printed at the beginning of the line before $PS1.