Extract the current attribute value up to a space or >.

This prevents us from getting the content of next tag in the current attribute value and thus fixes issue #3229.