Backslash in link URI is mishandled by the pdf backend
According to the doc for cairo_tag_begin()
regarding the attributes
string,
Single quotes and backslashes inside the string should be escaped with a backslash.
Therefore, it should work to do something like:
cairo_tag_begin (cr, CAIRO_TAG_LINK, "uri='http://example.org#\\\\' rect=[10 10 20 20]");
to create a link to the fragment identifier \
on the given page.
However, hovering over the resulting link in the generated PDF, evince shows a tooltip that suggests the link is malformed:
http://example.org#)
>>
/BS << /W 0 >>>>
It's pretty clear that the trailing backslash in the URI, although it was escaped in the string passed to cairo_tag_begin()
, has ended up escaping what should have been the closing delimiter of the PDF string.
If I doubly-escape the desired backslash, thus:
cairo_tag_begin (cr, CAIRO_TAG_LINK, "uri='http://example.org#\\\\\\\\' rect=[10 10 20 20]");
the resulting PDF has the expected link, with a target of http://example.org#\
. While this means I can work around the issue, it looks like incorrect behavior in cairo AFAICT.