The bookmark in Safari, like any web browser bookmark, contains a URI (URL); a JavaScript "bookmarklet" is no different: instead of an http: scheme that tells the browser to use a specific protocol to fetch a remote resource, a bookmarklet uses a javascript: scheme to tell the browser to parse the rest of the string as JavaScript code.
Note that, like other URLs, the JavaScript URL is percent-encoded, hence the many "%20" appearances that indicate encoded ⟨space⟩ characters.
The KM Execute JavaScript in Safari action doesn't take a URL as its input; it takes plain, unencoded JavaScript code. Therefore, to get your code to work, you need to do two things:
Remove the URI scheme, i.e. javascript:
Percent decode the URL string back into plain, unencoded text
Number ② in this situation is actually pretty straightforward, as the only encoded character is the ⟨space⟩ character. So everywhere you see "%20", just replace it with a ⟨space⟩.
The final code looks like this:
var docURL = document.URL;var open_link = window.open('','_blank');open_link.location=docURL;
which can (optionally) be reformatted to be a bit more readable into this:
var docURL = document.URL;
var open_link = window.open('','_blank');
open_link.location=docURL;
and then, finally—and, again, optionally—be simplified to this: