Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

headers: allow trailing whitespaces in uris #230

Merged
merged 1 commit into from
Aug 14, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions lib/rules/headers/dl.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ exports.check = function (sr, done) {
"\\/(\\d{4})\\/" +
(sr.config.status || "[A-Z]+") +
"-(.+)-(\\d{4})(\\d\\d)(\\d\\d)\\/?$";
var matches = ($linkThis.attr("href") || "").match(new RegExp(vThisRex))
var matches = ($linkThis.attr("href") || "").trim().match(new RegExp(vThisRex))
, docDate = sr.getDocumentDate()
;
if (matches) {
Expand Down Expand Up @@ -121,7 +121,7 @@ exports.check = function (sr, done) {
if (!$linkLate || !$linkLate.length || $linkLate.attr("href") !== $linkLate.text()) err("latest-link");

var lateRex = "^https?:\\/\\/www\\.w3\\.org\\/" + topLevel + "\\/(.+?)\\/?$"
, matches = ($linkLate.attr("href") || "").match(new RegExp(lateRex));
, matches = ($linkLate.attr("href") || "").trim().match(new RegExp(lateRex));
if (matches) {
var sn = matches[1];
latestURI = $linkLate.text();
Expand All @@ -136,7 +136,7 @@ exports.check = function (sr, done) {
if (!$linkPrev || !$linkPrev.length || $linkPrev.attr("href") !== $linkPrev.text()) err("previous-link");

var prevRex = "^https?:\\/\\/www\\.w3\\.org\\/" + topLevel + "\\/\\d{4}\\/[A-Z]+-(.+)-\\d{8}\\/?$"
, matches = ($linkPrev.attr("href") || "").match(new RegExp(prevRex))
, matches = ($linkPrev.attr("href") || "").trim().match(new RegExp(prevRex))
;
if (matches) {
var sn = matches[1];
Expand All @@ -151,7 +151,7 @@ exports.check = function (sr, done) {
var $linkResc = dts.Rescinds.dd.find("a").first();
if (!$linkResc || !$linkResc.length || $linkResc.attr("href") !== $linkResc.text()) err("rescinds-link");

var matches = ($linkResc.attr("href") || "").match(/^https?:\/\/www\.w3\.org\/TR\/\d{4}\/REC-(.+)-\d{8}\/?$/);
var matches = ($linkResc.attr("href") || "").trim().match(/^https?:\/\/www\.w3\.org\/TR\/\d{4}\/REC-(.+)-\d{8}\/?$/);
if (matches) {
var sn = matches[1];
if (sn !== shortname) err("this-rescinds-shortname");
Expand Down
1 change: 1 addition & 0 deletions test/all-rules.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ var tests = {
, errors: ["headers.dl", "headers.dl", "headers.dl", "headers.dl", "headers.dl", "headers.dl"]
, warnings: ["headers.dl"] }
, { doc: "headers/wrong-urls.html", errors: ["headers.dl", "headers.dl"], config: { previousVersion: true, status: "WD" } }
, { doc: "headers/dl-trailing-whitespace.html", config: { previousVersion: true, status: "WD" }, errors: ["headers.dl"] }
]
, "h2-status": [
{ doc: "headers/simple.html", config: { longStatus: "Working Draft" } }
Expand Down
86 changes: 86 additions & 0 deletions test/docs/headers/dl-trailing-whitespace.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
<!DOCTYPE html>
<html lang='en'>
<head>
<meta charset='utf-8'>
<title>Simple baseline headers valid document</title>
<!-- remove the below when CSS Validator is fixed -->
<style></style>
<link rel='stylesheet' href='http://www.w3.org/StyleSheets/TR/W3C-WD'>
</head>
<body>
<div class='head'>
<a href="http://www.w3.org/">
<img height="48" width="72" alt="W3C" src="http://www.w3.org/Icons/w3c_home">
</a>
<h1>Simple baseline headers valid document</h1>
<h2>W3C Working Draft 15 March 2017, edited in place 01 April 2014</h2>
<dl>
<dt>This Version:</dt>
<dd><a href='http://www.w3.org/TR/2017/WD-specberus-20170315/ '>http://www.w3.org/TR/2017/WD-specberus-20170315/ </a></dd>
<dt>Latest Version:</dt>
<dd><a href='http://www.w3.org/TR/specberus/ '>http://www.w3.org/TR/specberus/ </a></dd>
<dt>Previous Version:</dt>
<dd><a href='http://www.w3.org/TR/2017/WD-specberus-20170312/ '>http://www.w3.org/TR/2017/WD-specberus-20170312/ </a></dd>
<dt>Editor:</dt>
<dd>Specberus The Cranky</dd>
</dl>
<p class="copyright">
<a href="http://www.w3.org/Consortium/Legal/ipr-notice#Copyright">Copyright</a> © 1995-2017
<a href="http://trustee.ietf.org/">The IETF Trust</a> &amp;
<a href="http://www.w3.org/"><abbr title="World Wide Web Consortium">W3C</abbr></a><sup>®</sup>
(<a href="http://www.csail.mit.edu/"><abbr title="Massachusetts Institute of Technology">MIT</abbr></a>,
<a href="http://www.ercim.eu/"><abbr title="European Research Consortium for Informatics and Mathematics">ERCIM</abbr></a>,
<a href="http://www.keio.ac.jp/">Keio</a>,
<a href="http://ev.buaa.edu.cn/">Beihang</a>).
<abbr title="World Wide Web Consortium">W3C</abbr>
<a href="http://www.w3.org/Consortium/Legal/ipr-notice#Legal_Disclaimer">liability</a>,
<a href="http://www.w3.org/Consortium/Legal/ipr-notice#W3C_Trademarks">trademark</a> and
<a href="http://www.w3.org/Consortium/Legal/copyright-documents">document use</a>
rules apply.
</p>
<hr>
</div>
<h2>Abstract</h2>
<p>
We are the internets!
</p>
<h2>Status of This Document</h2>
<p><em>This section describes the status of this document at the time of its publication.
Other documents may supersede this document. A list of current W3C publications and the
latest revision of this technical report can be found in the
<a href="http://www.w3.org/TR/">W3C technical reports index</a> at
http://www.w3.org/TR/.</em></p>
<p>
If you wish to make comments regarding this document, please send them to
<a href="mailto:public-html@w3.org">public-html@w3.org</a>
(<a href="mailto:public-html-request@w3.org?subject=subscribe">subscribe</a>,
<a href="http://lists.w3.org/Archives/Public/public-html/">archives</a>).
</p>
<p>
It's a valid test!
</p>
<p>
Publication as a Working Draft does not imply endorsement by the W3C Membership. This is a
draft document and may be updated, replaced or obsoleted by other documents at any time. It is
inappropriate to cite this document as other than work in progress.
</p>
<p>
This document was produced by a group operating under the
<a id="sotd_patent" about="" rel="w3p:patentRules" href="http://www.w3.org/Consortium/Patent-Policy-20040205/">5 February 2004
<abbr title="World Wide Web Consortium">W3C</abbr> Patent Policy</a>.
<abbr title="World Wide Web Consortium">W3C</abbr> maintains a
<a href="http://www.w3.org/2004/01/pp-impl/40318/status" rel="disclosure">public list of
any patent disclosures</a> made in connection with the deliverables of the group; that page
also includes instructions for disclosing a patent. An individual who has actual knowledge of
a patent which the individual believes contains
<a href="http://www.w3.org/Consortium/Patent-Policy-20040205/#def-essential">Essential
Claim(s)</a> must disclose the information in accordance with
<a href="http://www.w3.org/Consortium/Patent-Policy-20040205/#sec-Disclosure">section 6 of the
<abbr title="World Wide Web Consortium">W3C</abbr> Patent Policy</a>.
</p>
<h2>Table of Contents</h2>
<ul>
<li>Nothing</li>
</ul>
</body>
</html>