jkitchin / org-ref

org-mode modules for citations, cross-references, bibliographies in org-mode and useful bibtex tools to go with it.
GNU General Public License v3.0
1.36k stars 243 forks source link

doi-utils-get-json-metadata should properly decode the data retrieved #1082

Closed piater closed 1 year ago

piater commented 1 year ago

doi-utils-get-json-metadata contains the following code:

      (with-current-buffer
          (url-retrieve-synchronously
           ;; (concat "http://dx.doi.org/" doi)
       url)
    (setq json-data (buffer-substring url-http-end-of-headers (point-max)))

For me, these cause two problems:

Thus, I suggest replacing the above code by the below:

      (with-temp-buffer
        (url-insert-buffer-contents (url-retrieve-synchronously url) url)
    (setq json-data (buffer-string))

This works for me but I cannot be 100% sure that the current→temp change does not break something somewhere...

jkitchin commented 1 year ago

hm. interesting. I use that pattern a lot in that file (and other places too). I guess it is mainly an issue for loading json though?

piater commented 1 year ago

Perhaps so. This is the only place it bit me. As long as you only extract ASCII material it should not matter. I also use your simple pattern in other places, without problems.

Actually, url-insert is sufficient (the extra power of url-insert-buffer-contents should not be needed) and does not require its own url argument.

jkitchin commented 1 year ago

any chance you have a doi where the current method fails?

jkitchin commented 1 year ago

I think the commit above should resolve this.