When you copy some HTML from a website that contains image tags and that image tags sources require authentication, the paste into another application that does not have those authentication credentials will not work.
I assumed, that the binary image data is copied when you hit CTRL+C, but this is not the case. Instead the image remains a image tag with a src attribute to the origin of the html.
I found a workaround, that google implemented in Google Drive and their other products, but this seems very hacky IMO: https://www.theverge.com/2015/6/23/8830977/google-photos-security-public-url-privacy-protected
Also this approach only happens to function, if the user has an active internet connection during CTRL+V (e.g. go to any wikipedia page, disable your network connection, Ctrl+A, Ctrl+C and Ctrl+V into any word document, and all images are missing).
I am currently using the javascript clipboard API (https://w3c.github.io/clipboard-apis/) to overwrite the image tags to include an external access token, when the user copies them for the first time. The external access tokens are then saved on the server side to enable a request without authentication to the image source.
The resulting HTML in the clipboard looks something like the following example:
<p>Lorem Ipsum Dolor sit amet <img src="http://example.com/images/SomeSecuredImage.jpg?securitytoken=ABCDEFGHIJK..." /></p>
Is anyone aware of other solutions for this problem, or is the "Google" approach the only one out there.
Thanks!
EDIT
I have some html documents and images secured by a login mechanism that my users can open in their web browsers after logging into our system. As long as they are logged in, they can load the html documents and images, but as soon as they are trying to select some text including images and copy it, they are not able to paste the contents including the images into another application like word, because word is not authenticated like the browser is, so only the text is copied.
I have already tried to debug the problem and validated, that word itself is making a request to fetch the images after hitting CTRL+V inside word.
So maybe someone knows a different solution than the mentioned random URL solution, thanks :-)
from Copy images from secured website to word (or other applications)
No comments:
Post a Comment