Apparently some PDF files can have annotations with `URI` entries ending with `null` characters, thus breaking the links. To handle this edge-case of bad PDFs, this patch moves the already existing utility function from `ui_utils.js` into `util.js`, in order to fix those URLs. Fixes 6832.