Make V2 code more defensive against malformed content Upstream-commit: 9f482a66ab37ec396ac61ed0c00d59122ac07453 Component: engine