Encode Content-ID before inserting into HTML

Also, watch for null when fetching node from the DOM.