latex3 / hyperref

Hypertext support for LaTeX
168 stars 37 forks source link

URL Encoding Issue #88

Closed KTS915 closed 5 years ago

KTS915 commented 5 years ago

The latest version (or maybe it was the one before) is percent-encoding URLs in hyperlinks, but in such a way that they do not work as expected.

Take this URL, for example, for a resource on Google Scholar, which works fine: https://scholar.google.com/scholar_case?case=15509503170515180438&q=Kiobel+v.+Royal+Dutch+Petroleum+Co.&hl=en&num=20&as_sdt=40006

Hyperref causes this to be changed to the following: https://scholar.google.com/scholar_case%3Fcase%3D15509503170515180438%26q%3DKiobel%2Bv.%2BRoyal%2BDutch%2BPetroleum%2BCo.%26hl%3Den%26num%3D20%26as_sdt%3D40006

As you will see, Google now reports an error.

Here's another valid URL: https://scholarship.law.berkeley.edu/cgi/viewcontent.cgi?article=2755&context=facpubs

But hyperref changes it to this: https://scholarship.law.berkeley.edu/cgi/viewcontent.cgi%3Farticle%3D2755%26context%3Dfacpubs

Which is greeted with the following message: "Sorry, we can't find the page you're looking for!"

u-fischer commented 5 years ago

Both url work fine for me, when using them in a small document compiled with pdflatex.

Show a complete minimal example, and also say how you are compiling.

KTS915 commented 5 years ago

Thanks for responding so quickly. I am using LyX, but I get the same result if I use native LaTeX with Gummi instead. Here's a minimal example:

%% LyX 2.3.2 created this file.  For more info, see http://www.lyx.org/.
%% Do not edit unless you really know what you are doing.
\documentclass{scrartcl}
\usepackage{charter}
\usepackage{tgheros}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage{geometry}
\geometry{verbose,bmargin=1.25in}
\setlength{\parskip}{\medskipamount}
\setlength{\parindent}{0pt}
\usepackage{color}
\usepackage{array}
\usepackage{url}
\usepackage{enumitem}
\usepackage{setspace}
\usepackage[unicode=true,
 bookmarks=true,bookmarksnumbered=false,bookmarksopen=false,
 breaklinks=true,pdfborder={0 0 0},pdfborderstyle={},backref=false,colorlinks=true]
 {hyperref}
\hypersetup{linkcolor=blue, citecolor=blue, urlcolor=blue, unicode=true}

\makeatletter

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% LyX specific LaTeX commands.
%% Because html converters don't know tabularnewline
\providecommand{\tabularnewline}{\\}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Textclass specific LaTeX commands.
\newlength{\lyxlabelwidth}      % auxiliary length 

\@ifundefined{date}{}{\date{}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands.
\frenchspacing

\renewcommand{\arraystretch}{2}

\makeatother

\begin{document}
\title{ADVANCED TORTS SEMINAR: SYLLABUS }
\maketitle

\section*{Course structure}

\subsection*{Assigned book}
\emph{Kiobel v. Royal Dutch Petroleum Co.}, \href{https://scholar.google.com/scholar_case\%3Fcase\%3D15509503170515180438\%26q\%3DKiobel\%2Bv.\%2BRoyal\%2BDutch\%2BPetroleum\%2BCo.\%26hl\%3Den\%26num\%3D20\%26as_sdt\%3D40006}{569 U.S. 108}
(2013)
\tabularnewline
Paul M. Schwartz \& Karl-Nikolaus Peifer, \emph{Prosser's
Privacy and the German Right of Personality: Are Four Privacy Torts
Better than One Unitary Concept?} \href{https://scholarship.law.berkeley.edu/cgi/viewcontent.cgi\%3Farticle\%3D2755\%26context\%3Dfacpubs}{98 Cal. L. Rev. 1925}
(2010)\tabularnewline
\end{document}
u-fischer commented 5 years ago

You have the percent encoding already in the source: viewcontent.cgi\%3Farticle\%3D2755

KTS915 commented 5 years ago

Yes, I see. I exported that from LyX. So that suggests that LyX is encoding the URL before the URL gets compiled by hyperref, which is then encoding it again. Hence the problem. Does that makes sense to you as an explanation?

u-fischer commented 5 years ago

It looks like a lyx problem and not a hyperref problem, so I'm closing the issue here.