robots-parser 3.1.1 → 3.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +5 -0
- package/README.md +5 -0
- package/Robots.js +6 -3
- package/package.json +1 -1
- package/test/Robots.js +30 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## Version 3.1.2
|
|
4
|
+
|
|
5
|
+
- Fixed bug with non-encoded special characters in `allow` and `disallow` paths, and now handles non-encoded spaces inside paths.
|
|
6
|
+
– Thanks to @bardrop for reporting and fixing.
|
|
7
|
+
|
|
3
8
|
## Version 3.1.1
|
|
4
9
|
|
|
5
10
|
- Fixed bug from 3.1.0 with sitemap, crawl-delay, host and unknown directives not terminating groups.
|
package/README.md
CHANGED
|
@@ -112,6 +112,11 @@ Returns the preferred host name specified by the `host:` directive or null if th
|
|
|
112
112
|
|
|
113
113
|
# Changes
|
|
114
114
|
|
|
115
|
+
## Version 3.1.2
|
|
116
|
+
|
|
117
|
+
- Fixed bug with non-encoded special characters in `allow` and `disallow` paths, and now handles non-encoded spaces inside paths.
|
|
118
|
+
– Thanks to @bardrop for reporting and fixing.
|
|
119
|
+
|
|
115
120
|
## Version 3.1.1
|
|
116
121
|
|
|
117
122
|
- Fixed bug from 3.1.0 with sitemap, crawl-delay, host and unknown directives not terminating groups.
|
package/Robots.js
CHANGED
|
@@ -76,7 +76,8 @@ function formatUserAgent(userAgent) {
|
|
|
76
76
|
|
|
77
77
|
/**
|
|
78
78
|
* Normalises the URL encoding of a path by encoding
|
|
79
|
-
* unicode characters
|
|
79
|
+
* unicode characters and ASCII characters that are not
|
|
80
|
+
* allowed in a URL.
|
|
80
81
|
*
|
|
81
82
|
* @param {string} path
|
|
82
83
|
* @return {string}
|
|
@@ -84,8 +85,10 @@ function formatUserAgent(userAgent) {
|
|
|
84
85
|
*/
|
|
85
86
|
function normaliseEncoding(path) {
|
|
86
87
|
try {
|
|
87
|
-
// Encode any non-ASCII chars
|
|
88
|
-
|
|
88
|
+
// Encode any non-ASCII chars and the ASCII chars that are not allowed
|
|
89
|
+
// in a URL (the URL parser encodes most of these in paths, so the
|
|
90
|
+
// patterns must be encoded the same way to match)
|
|
91
|
+
return safeDecodeURI(path).replace(/[^\x00-\x7F]|[\x00-\x20"<>\\^`{|}\x7F]/gu, (char) => {
|
|
89
92
|
return encodeURIComponent(char).toUpperCase();
|
|
90
93
|
});
|
|
91
94
|
} catch (e) {
|
package/package.json
CHANGED
package/test/Robots.js
CHANGED
|
@@ -536,6 +536,36 @@ describe('Robots', function () {
|
|
|
536
536
|
testRobots('http://www.example.com/robots.txt', contents, allowed, disallowed);
|
|
537
537
|
});
|
|
538
538
|
|
|
539
|
+
it('should match characters the URL parser percent-encodes', function () {
|
|
540
|
+
var contents = [
|
|
541
|
+
'User-agent: *',
|
|
542
|
+
'Disallow: /a b',
|
|
543
|
+
'Disallow: /*"',
|
|
544
|
+
'Disallow: /*{',
|
|
545
|
+
'Disallow: /*^',
|
|
546
|
+
'Disallow: /c|d',
|
|
547
|
+
'Disallow: /e%7Cf'
|
|
548
|
+
].join('\n');
|
|
549
|
+
|
|
550
|
+
var allowed = [
|
|
551
|
+
'http://www.example.com/ab',
|
|
552
|
+
'http://www.example.com/c'
|
|
553
|
+
];
|
|
554
|
+
|
|
555
|
+
var disallowed = [
|
|
556
|
+
'http://www.example.com/a b',
|
|
557
|
+
'http://www.example.com/a%20b',
|
|
558
|
+
'http://www.example.com/x"',
|
|
559
|
+
'http://www.example.com/x{y}',
|
|
560
|
+
'http://www.example.com/x^y',
|
|
561
|
+
'http://www.example.com/c|d',
|
|
562
|
+
'http://www.example.com/c%7Cd',
|
|
563
|
+
'http://www.example.com/e|f'
|
|
564
|
+
];
|
|
565
|
+
|
|
566
|
+
testRobots('http://www.example.com/robots.txt', contents, allowed, disallowed);
|
|
567
|
+
});
|
|
568
|
+
|
|
539
569
|
it('should handle lone high / low surrogates', function () {
|
|
540
570
|
var contents = [
|
|
541
571
|
'User-agent: *',
|