andras-simonyi / citeproc-el

A CSL 1.0.2 Citation Processor for Emacs.
GNU General Public License v3.0
85 stars 9 forks source link

% not escaped in LaTeX exports #56

Closed tecosaur closed 2 years ago

tecosaur commented 2 years ago

I'm trying to export a citation with a few % chars in the URL, and looking at the generated .tex it seems like they're not escaped :slightly_frowning_face:.

andras-simonyi commented 2 years ago

Thanks for reporting this! Just for the sake of completeness, could you specify the offending bibliography entry? (It can matter whether it was a bib(lat)ex or a CSL-JSON entry.)

tecosaur commented 2 years ago

Looking at the entry, I'm suspicious of the BetterBibLaTeX export, but this is what I have:

@online{FunctionalDataGoogle,
  title = {"functional Data" - {{Google Scholar}}},
  url = {https://scholar.google.com/scholar?q=%22functional+data%22},
  urldate = {2021-05-07},
  organization = {{Google Scholar}}
}
tecosaur commented 2 years ago

Thanks for taking care of this :slightly_smiling_face:

denismaier commented 2 years ago

Just a quick note on the BetterBibLaTeX export: I think the export is not to blame here. I have found this in the biblatex manual (p. 17):

URI fields are processed in verbatim mode and may contain special characters. They are also URL-escaped if they don’t look like they already are. The typical example of a uri field is url.

So, while it would be necessary to escape a % in other fields, e.g. title, it's not necessary to do so in url.

tecosaur commented 2 years ago

Interesting. Thanks for chiming in.

denismaier commented 2 years ago

Anyway, I think you shouldn't use biblatex databases when using citeproc. Using the "Better CSLJSON" exporter should give you more accurate results. (I.e., the advice from here concerning pandoc should also be valid for org.)

andras-simonyi commented 2 years ago

Well, for better or worse the code for LaTeX formatting now escapes any percent character in an URI that is the value of a href attribute in the generated internal rich-text representation. If some people/tools already escape them in the entry (maybe for BibTeX???) then this needs to be refined. UPDATE: I will probably do this as a safety measure anyway.

tecosaur commented 2 years ago

Looking at other entries, I see that in other fields % signs are escaped.

andras-simonyi commented 2 years ago

Thanks, meanwhile I've checked it and fortunately the issue is already handled by the bib(la)tex decoder so it shouldn't matter whether the URIs are percent-escaped in the entry or not.