mirror of https://github.com/zcash/zips.git
protocol/links_and_dests.py: Some DOI links (i.e. to https://doi.org/) redirect to link.springer.com
in a way that requires cookies (booo!). We allow this for DOI links, but for all other links we simulate a client that never sets cookies. Signed-off-by: Daira Hopwood <daira@jacaranda.org>
This commit is contained in:
parent
a918bbc6d7
commit
a5c4f139c9
|
@ -7,7 +7,7 @@ except ImportError:
|
||||||
print("Please install the PyPDF2 library using `pip3 install PyPDF2`.\n")
|
print("Please install the PyPDF2 library using `pip3 install PyPDF2`.\n")
|
||||||
raise
|
raise
|
||||||
|
|
||||||
from urllib.request import urlopen, Request
|
from urllib.request import build_opener, HTTPCookieProcessor, Request
|
||||||
from urllib.error import URLError
|
from urllib.error import URLError
|
||||||
from os.path import basename
|
from os.path import basename
|
||||||
from collections import deque
|
from collections import deque
|
||||||
|
@ -78,8 +78,15 @@ def main(args):
|
||||||
elif check:
|
elif check:
|
||||||
try:
|
try:
|
||||||
headers = {"User-Agent": "Mozilla/5.0"}
|
headers = {"User-Agent": "Mozilla/5.0"}
|
||||||
res = urlopen(Request(url=l, headers=headers))
|
# Some DOI links (i.e. to https://doi.org/) redirect to link.springer.com
|
||||||
res.read()
|
# in a way that requires cookies (booo!). We allow this for DOI links,
|
||||||
|
# but for all other links we simulate a client that never sets cookies.
|
||||||
|
if l.startswith("https://doi.org/"):
|
||||||
|
opener = build_opener(HTTPCookieProcessor())
|
||||||
|
else:
|
||||||
|
opener = build_opener()
|
||||||
|
response = opener.open(Request(url=l, headers=headers))
|
||||||
|
response.read()
|
||||||
status = "✓"
|
status = "✓"
|
||||||
except URLError as e:
|
except URLError as e:
|
||||||
errors.append("Could not open link: %s due to %r" % (what, e))
|
errors.append("Could not open link: %s due to %r" % (what, e))
|
||||||
|
|
|
@ -14511,6 +14511,8 @@ Peter Newell's illustration of the Jubjub bird, from \cite{Carroll1902}.
|
||||||
} %nufive
|
} %nufive
|
||||||
\item Fix a reference to nonexistent version 2019.0-beta-40 of this specification
|
\item Fix a reference to nonexistent version 2019.0-beta-40 of this specification
|
||||||
(in \crossref{diffadjustment}) that should be \historyref{2019.0.0}.
|
(in \crossref{diffadjustment}) that should be \historyref{2019.0.0}.
|
||||||
|
\item Improve \texttt{protocol/links\_and\_dests.py} to eliminate false positives
|
||||||
|
when checking DOI links.
|
||||||
\end{itemize}
|
\end{itemize}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue