Make js offset parsing stricter

Fixes #2927