@whotracksme/reporting 5.1.17
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/.editorconfig +12 -0
- package/.eslintignore +3 -0
- package/.eslintrc +16 -0
- package/.github/workflows/release.yml +34 -0
- package/.github/workflows/tests.yml +20 -0
- package/.prettierrc +9 -0
- package/.tool-versions +1 -0
- package/CHANGELOG.md +795 -0
- package/LICENSE +373 -0
- package/README.md +1 -0
- package/communication/README.md +11 -0
- package/communication/example/index.js +43 -0
- package/communication/example/manifest.json +16 -0
- package/communication/karma.conf.cjs +19 -0
- package/communication/package.json +52 -0
- package/communication/rollup.common-config.cjs +17 -0
- package/communication/rollup.config.cjs +10 -0
- package/communication/src/encoding.js +54 -0
- package/communication/src/errors.js +84 -0
- package/communication/src/index.js +76 -0
- package/communication/src/logger.js +41 -0
- package/communication/src/padding.js +60 -0
- package/communication/src/proxied-http.js +231 -0
- package/communication/src/server-public-key-accessor.js +123 -0
- package/communication/src/timestamps.js +37 -0
- package/communication/src/trusted-clock.js +58 -0
- package/communication/src/utils.js +28 -0
- package/communication/src/zlib.js +17 -0
- package/communication/test/helpers/in-memory-database.js +43 -0
- package/communication/test/server-public-key-accessor.spec.js +135 -0
- package/communication/test/utils.spec.js +43 -0
- package/package.json +50 -0
- package/reporting/TODO.md +2 -0
- package/reporting/assets/request/bloom_filter.dat +0 -0
- package/reporting/assets/request/update.json +1 -0
- package/reporting/example/content.js +11 -0
- package/reporting/example/index.js +132 -0
- package/reporting/example/inspector/index.html +17 -0
- package/reporting/example/inspector/index.js +27 -0
- package/reporting/example/manifests/chromium.json +37 -0
- package/reporting/example/manifests/firefox.json +35 -0
- package/reporting/example/rules.json +62 -0
- package/reporting/example/setup.js +1 -0
- package/reporting/example/tests/test1.html +10 -0
- package/reporting/karma.conf.cjs +22 -0
- package/reporting/package.json +63 -0
- package/reporting/rollup.common-config.cjs +19 -0
- package/reporting/rollup.config.cjs +20 -0
- package/reporting/src/LRU.js +149 -0
- package/reporting/src/activity-estimator.js +298 -0
- package/reporting/src/alive-check.js +139 -0
- package/reporting/src/alive-message-generator.js +142 -0
- package/reporting/src/bloom-filters.js +345 -0
- package/reporting/src/country-provider.js +295 -0
- package/reporting/src/cyrb53.js +32 -0
- package/reporting/src/digest.js +33 -0
- package/reporting/src/doublefetch-page-handler.js +548 -0
- package/reporting/src/duplicate-detector.js +233 -0
- package/reporting/src/errors.js +84 -0
- package/reporting/src/event-listener-queue.js +121 -0
- package/reporting/src/fixed-size-cache.js +63 -0
- package/reporting/src/hash-detector.js +1526 -0
- package/reporting/src/html-parser.js +17 -0
- package/reporting/src/http.js +265 -0
- package/reporting/src/index.js +14 -0
- package/reporting/src/job-scheduler.js +912 -0
- package/reporting/src/logger.js +121 -0
- package/reporting/src/md5.js +334 -0
- package/reporting/src/message-sender.js +51 -0
- package/reporting/src/network.js +140 -0
- package/reporting/src/new-page-approver.js +119 -0
- package/reporting/src/page-aggregator.js +185 -0
- package/reporting/src/page-quorum-check-handler.js +200 -0
- package/reporting/src/page-structure.js +136 -0
- package/reporting/src/pagedb.js +671 -0
- package/reporting/src/pages.js +1798 -0
- package/reporting/src/patterns-updater.js +310 -0
- package/reporting/src/patterns.js +416 -0
- package/reporting/src/persisted-bitarray.js +265 -0
- package/reporting/src/persisted-hashes.js +189 -0
- package/reporting/src/quorum-checker.js +327 -0
- package/reporting/src/random.js +39 -0
- package/reporting/src/reporting.js +290 -0
- package/reporting/src/request/config.js +116 -0
- package/reporting/src/request/content-script.js +77 -0
- package/reporting/src/request/database.js +147 -0
- package/reporting/src/request/dnt.js +24 -0
- package/reporting/src/request/hash.js +101 -0
- package/reporting/src/request/index.js +874 -0
- package/reporting/src/request/page-telemetry.js +42 -0
- package/reporting/src/request/qs-whitelist2.js +247 -0
- package/reporting/src/request/resources/prob.js +601 -0
- package/reporting/src/request/steps/block-rules.js +40 -0
- package/reporting/src/request/steps/check-context.js +37 -0
- package/reporting/src/request/steps/cookie-context.js +209 -0
- package/reporting/src/request/steps/oauth-detector.js +101 -0
- package/reporting/src/request/steps/page-logger.js +177 -0
- package/reporting/src/request/steps/redirect-tagger.js +75 -0
- package/reporting/src/request/steps/subdomain-check.js +34 -0
- package/reporting/src/request/steps/token-checker/index.js +189 -0
- package/reporting/src/request/steps/token-checker/token-domain.js +129 -0
- package/reporting/src/request/steps/token-examiner.js +182 -0
- package/reporting/src/request/steps/token-telemetry/cached-entry-pipeline.js +210 -0
- package/reporting/src/request/steps/token-telemetry/index.js +234 -0
- package/reporting/src/request/steps/token-telemetry/key-pipeline.js +109 -0
- package/reporting/src/request/steps/token-telemetry/token-pipeline.js +105 -0
- package/reporting/src/request/time.js +73 -0
- package/reporting/src/request/utils/bloom-filter-packed.js +107 -0
- package/reporting/src/request/utils/chrome-storage-map.js +282 -0
- package/reporting/src/request/utils/subject.js +37 -0
- package/reporting/src/request/utils/temp-set.js +56 -0
- package/reporting/src/request/utils/tlds.js +55 -0
- package/reporting/src/request/utils.js +41 -0
- package/reporting/src/request-reporter.js +111 -0
- package/reporting/src/sanitizer.js +519 -0
- package/reporting/src/search-extractor.js +338 -0
- package/reporting/src/self-check.js +105 -0
- package/reporting/src/seq-executor.js +43 -0
- package/reporting/src/session-storage.js +399 -0
- package/reporting/src/url-analyzer.js +161 -0
- package/reporting/src/url-cleaner.js +60 -0
- package/reporting/src/utils/pacemaker.js +279 -0
- package/reporting/src/utils/url.js +114 -0
- package/reporting/src/utils.js +345 -0
- package/reporting/src/webrequest-pipeline/cname-uncloak.js +110 -0
- package/reporting/src/webrequest-pipeline/index.js +287 -0
- package/reporting/src/webrequest-pipeline/logger.js +14 -0
- package/reporting/src/webrequest-pipeline/page-store.js +282 -0
- package/reporting/src/webrequest-pipeline/page.js +140 -0
- package/reporting/src/webrequest-pipeline/pipeline.js +249 -0
- package/reporting/src/webrequest-pipeline/utils/webrequest.js +113 -0
- package/reporting/src/webrequest-pipeline/webrequest-context.js +153 -0
- package/reporting/test/README.md +2 -0
- package/reporting/test/activity-estimator.spec.js +356 -0
- package/reporting/test/alive-check.spec.js +156 -0
- package/reporting/test/alive-message-generator.spec.js +186 -0
- package/reporting/test/country-provider.spec.js +263 -0
- package/reporting/test/doublefetch-page-handler.spec.js +818 -0
- package/reporting/test/duplicate-detector.spec.js +689 -0
- package/reporting/test/helpers/dom-parsers.js +41 -0
- package/reporting/test/helpers/fake-session-storage.js +69 -0
- package/reporting/test/helpers/fast-check-utils.js +28 -0
- package/reporting/test/helpers/fetch-mock.js +57 -0
- package/reporting/test/helpers/in-memory-database.js +14 -0
- package/reporting/test/helpers/memory-map.js +72 -0
- package/reporting/test/helpers/pagedb-mocks.js +41 -0
- package/reporting/test/index.js +47 -0
- package/reporting/test/job-scheduler.spec.js +691 -0
- package/reporting/test/network.spec.js +72 -0
- package/reporting/test/page-aggregator.spec.js +104 -0
- package/reporting/test/page-quorum-check-handler.spec.js +86 -0
- package/reporting/test/pagedb.spec.js +250 -0
- package/reporting/test/pages.spec.js +693 -0
- package/reporting/test/patterns-updater.spec.js +446 -0
- package/reporting/test/patterns.spec.js +751 -0
- package/reporting/test/persisted-hashes.spec.js +169 -0
- package/reporting/test/reporting.spec.js +205 -0
- package/reporting/test/request/database.spec.js +59 -0
- package/reporting/test/request/hash.spec.js +108 -0
- package/reporting/test/request/index.spec.js +378 -0
- package/reporting/test/request/qs-whitelist2.spec.js +189 -0
- package/reporting/test/request/steps/check-context.spec.js +51 -0
- package/reporting/test/request/steps/oauth-detector.spec.js +339 -0
- package/reporting/test/request/test-pages.js +1246 -0
- package/reporting/test/request/utils/bloom-filter-packed.spec.js +37 -0
- package/reporting/test/request/utils/chrome-storage-map.spec.js +28 -0
- package/reporting/test/request/utils/tldts.spec.js +62 -0
- package/reporting/test/request/utils.spec.js +168 -0
- package/reporting/test/sanitizer.spec.js +1087 -0
- package/reporting/test/search-extractor.spec.js +590 -0
- package/reporting/test/seq-executor.spec.js +158 -0
- package/reporting/test/session-storage.spec.js +400 -0
- package/reporting/test/setup.js +24 -0
- package/reporting/test/url-analyzer.spec.js +451 -0
- package/reporting/test/url-cleaner.spec.js +102 -0
- package/reporting/test/utils/pacemaker.spec.js +222 -0
- package/reporting/test/utils/url.spec.js +660 -0
- package/reporting/test/utils.spec.js +299 -0
- package/reporting/test/webrequest-pipeline/pipeline.spec.js +251 -0
|
@@ -0,0 +1,1087 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WhoTracks.Me
|
|
3
|
+
* https://whotracks.me/
|
|
4
|
+
*
|
|
5
|
+
* Copyright 2017-present Ghostery GmbH. All rights reserved.
|
|
6
|
+
*
|
|
7
|
+
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
8
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
9
|
+
* file, You can obtain one at http://mozilla.org/MPL/2.0
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import { expect } from 'chai';
|
|
13
|
+
import fc from 'fast-check';
|
|
14
|
+
|
|
15
|
+
import {
|
|
16
|
+
sanitizeUrl,
|
|
17
|
+
checkSuspiciousQuery,
|
|
18
|
+
isValidEAN13,
|
|
19
|
+
isValidISSN,
|
|
20
|
+
} from '../src/sanitizer.js';
|
|
21
|
+
|
|
22
|
+
describe('#checkSuspiciousQuery', function () {
|
|
23
|
+
function shouldBeSafe(query) {
|
|
24
|
+
const { accept, reason } = checkSuspiciousQuery(query);
|
|
25
|
+
expect(accept).to.eql(true);
|
|
26
|
+
expect(reason).to.be.undefined;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function shouldBeDropped(query) {
|
|
30
|
+
const { accept, reason } = checkSuspiciousQuery(query);
|
|
31
|
+
expect(accept).to.eql(false);
|
|
32
|
+
expect(reason).to.be.a('string').that.is.not.empty;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
describe('should accept simple, normal queries', function () {
|
|
36
|
+
for (const safeQuery of [
|
|
37
|
+
'munich',
|
|
38
|
+
'joe biden',
|
|
39
|
+
'what is the meaning of life?',
|
|
40
|
+
'best android phone in 2023',
|
|
41
|
+
]) {
|
|
42
|
+
it(`should accept: ${safeQuery}`, function () {
|
|
43
|
+
shouldBeSafe(safeQuery);
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
describe('should drop queries with overly long words', function () {
|
|
49
|
+
for (const unsafeQuery of [
|
|
50
|
+
'UniversitätsverwaltungsdirektorinnenUniversitätsverwaltungsdirektorinnenUniversitätsverwaltungsdirektorinnen',
|
|
51
|
+
'universitätsverwaltungsdirektorinnenuniversitätsverwaltungsdirektorinnenuniversitätsverwaltungsdirektorinnen',
|
|
52
|
+
'Some query containing an overlong word like universitätsverwaltungsdirektorinnenuniversitätsverwaltungsdirektorinnenuniversitätsverwaltungsdirektorinnen',
|
|
53
|
+
]) {
|
|
54
|
+
it(`should reject: ${unsafeQuery}`, function () {
|
|
55
|
+
shouldBeDropped(unsafeQuery);
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
for (const safeQuery of [
|
|
60
|
+
'Abarbeitungsgeschwindigkeit',
|
|
61
|
+
'abarbeitungsgeschwindigkeit',
|
|
62
|
+
'Abgeordnetenentschädigungen',
|
|
63
|
+
'abgeordnetenentschädigungen',
|
|
64
|
+
'Unfallentschädigungsbehörde',
|
|
65
|
+
'Universitätsverwaltungsdirektorinnen',
|
|
66
|
+
'universitätsverwaltungsdirektorinnen',
|
|
67
|
+
'Some query containing a long word like Universitätsverwaltungsdirektorinnen',
|
|
68
|
+
]) {
|
|
69
|
+
it(`should accept: ${safeQuery}`, function () {
|
|
70
|
+
shouldBeSafe(safeQuery);
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
describe('should drop queries with overly long text', function () {
|
|
76
|
+
for (const unsafeQuery of [
|
|
77
|
+
'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.',
|
|
78
|
+
]) {
|
|
79
|
+
it(`should reject: ${unsafeQuery}`, function () {
|
|
80
|
+
shouldBeDropped(unsafeQuery);
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
for (const safeQuery of [
|
|
85
|
+
'how many champions league tournaments have been held',
|
|
86
|
+
'Is life an arbitrary stage in the growing complexity of matter?',
|
|
87
|
+
]) {
|
|
88
|
+
it(`should accept: ${safeQuery}`, function () {
|
|
89
|
+
shouldBeSafe(safeQuery);
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
describe('should be more conservative with limits for languages such as Chinese or Japanese', function () {
|
|
95
|
+
for (const unsafeQuery of [
|
|
96
|
+
// lorem impsum auto-translated
|
|
97
|
+
'痛苦本身是巨大的,令人悲伤的事情已经解决了,但是', // Chinese
|
|
98
|
+
'痛み自体は大きく、悲しみのエリートは解決しましたが、一時', // Japanese
|
|
99
|
+
'ความเจ็บปวดนั้นยอดเยี่ยมมาก ความทุกข์ระทมก็สงบลง', // Thai
|
|
100
|
+
'고통 자체는 크며, 슬픈 elitr은 해결되었지만 diam nonumy eirmo는 한동안 노동과 고통으로 대단한 일 이었지만', // Korean
|
|
101
|
+
]) {
|
|
102
|
+
it(`should reject: ${unsafeQuery}`, function () {
|
|
103
|
+
shouldBeDropped(unsafeQuery);
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
for (const safeQuery of [
|
|
108
|
+
// "weather munich" auto-translated
|
|
109
|
+
'天气慕尼黑',
|
|
110
|
+
'天気 ミュンヘン',
|
|
111
|
+
'สภาพอากาศ มิวนิค',
|
|
112
|
+
'날씨 뮌헨',
|
|
113
|
+
]) {
|
|
114
|
+
it(`should accept: ${safeQuery}`, function () {
|
|
115
|
+
shouldBeSafe(safeQuery);
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
describe('should support languages with different alphabets', function () {
|
|
121
|
+
for (const safeQuery of [
|
|
122
|
+
// "some dummy text" auto-translated
|
|
123
|
+
'какой-то фиктивный текст',
|
|
124
|
+
'بعض النصوص الوهمية',
|
|
125
|
+
'איזה טקסט דמה',
|
|
126
|
+
'कुछ नकली पाठ',
|
|
127
|
+
]) {
|
|
128
|
+
it(`should accept: ${safeQuery}`, function () {
|
|
129
|
+
shouldBeSafe(safeQuery);
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
describe('should support special letters', function () {
|
|
135
|
+
for (const safeQuery of [
|
|
136
|
+
'German text äößÖÄ€',
|
|
137
|
+
'French text éèêë',
|
|
138
|
+
'Swedish text åÅ',
|
|
139
|
+
'Polish text ąęśŚ',
|
|
140
|
+
'Turkish text ÇĞİÖŞÜ',
|
|
141
|
+
]) {
|
|
142
|
+
it(`should accept: ${safeQuery}`, function () {
|
|
143
|
+
shouldBeSafe(safeQuery);
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
describe('should drop searches containing phone numbers', function () {
|
|
149
|
+
for (const unsafeQuery of [
|
|
150
|
+
'089 / 123 456 789',
|
|
151
|
+
'(0)89 123456789',
|
|
152
|
+
'089123456789',
|
|
153
|
+
'+4989123456789',
|
|
154
|
+
'089 - 1234 567 89',
|
|
155
|
+
'some text 089 - 1234 567 89',
|
|
156
|
+
'some 089 - 1234 567 89 text',
|
|
157
|
+
'089 - 1234 567 89 some text',
|
|
158
|
+
]) {
|
|
159
|
+
it(`should reject: ${unsafeQuery}`, function () {
|
|
160
|
+
shouldBeDropped(unsafeQuery);
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
describe('should not drop EAN numbers', function () {
|
|
166
|
+
for (const safeQuery of [
|
|
167
|
+
'9780345418913',
|
|
168
|
+
'9780345418913 some text',
|
|
169
|
+
'some 9780345418913 text',
|
|
170
|
+
]) {
|
|
171
|
+
it(`should accept: ${safeQuery}`, function () {
|
|
172
|
+
shouldBeSafe(safeQuery);
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
for (const unsafeQuery of [
|
|
177
|
+
'9780345418912',
|
|
178
|
+
'9780345418912 some text',
|
|
179
|
+
'some 9780345418912 text',
|
|
180
|
+
]) {
|
|
181
|
+
it(`should drop invalid EANs: ${unsafeQuery}`, function () {
|
|
182
|
+
shouldBeDropped(unsafeQuery);
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
describe('should not drop ISSN numbers', function () {
|
|
188
|
+
for (const safeQuery of [
|
|
189
|
+
'2049-3630',
|
|
190
|
+
'2049-3630 some text',
|
|
191
|
+
'some 2049-3630 text',
|
|
192
|
+
]) {
|
|
193
|
+
it(`should accept: ${safeQuery}`, function () {
|
|
194
|
+
shouldBeSafe(safeQuery);
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
for (const unsafeQuery of [
|
|
199
|
+
'2049-3631',
|
|
200
|
+
'2049-3631 some text',
|
|
201
|
+
'some 2049-3631 text',
|
|
202
|
+
]) {
|
|
203
|
+
it(`should drop invalid ISSNs: ${unsafeQuery}`, function () {
|
|
204
|
+
shouldBeDropped(unsafeQuery);
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
describe('should drop searches containing email addresses', function () {
|
|
210
|
+
for (const unsafeQuery of [
|
|
211
|
+
'my.name@example.test',
|
|
212
|
+
'some text my.name@example.test',
|
|
213
|
+
'some my.name@example.test text',
|
|
214
|
+
'my.name@example.test some text',
|
|
215
|
+
]) {
|
|
216
|
+
it(`should reject: ${unsafeQuery}`, function () {
|
|
217
|
+
shouldBeDropped(unsafeQuery);
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
});
|
|
221
|
+
|
|
222
|
+
describe('should drop searches containing HTTP passwords', function () {
|
|
223
|
+
for (const unsafeQuery of [
|
|
224
|
+
'user:password@example.test',
|
|
225
|
+
'some text user:password@example.text',
|
|
226
|
+
'some user:password@example.test text',
|
|
227
|
+
'user:password@example.test some text',
|
|
228
|
+
]) {
|
|
229
|
+
it(`should reject: ${unsafeQuery}`, function () {
|
|
230
|
+
shouldBeDropped(unsafeQuery);
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
});
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
describe('#sanitizeUrl', function () {
|
|
237
|
+
// to test URLs that are generally safe and should be accepted both in
|
|
238
|
+
// normal mode and strict mode
|
|
239
|
+
function shouldBeSafe(url) {
|
|
240
|
+
{
|
|
241
|
+
const { result, safeUrl, reason } = sanitizeUrl(url);
|
|
242
|
+
if (result !== 'safe') {
|
|
243
|
+
expect.fail(
|
|
244
|
+
`Expected the URL ${url} to be safe, but it was rejected: ${reason}`,
|
|
245
|
+
);
|
|
246
|
+
}
|
|
247
|
+
expect(safeUrl).to.eql(url);
|
|
248
|
+
expect(reason).to.be.undefined;
|
|
249
|
+
}
|
|
250
|
+
{
|
|
251
|
+
const { result, safeUrl, reason } = sanitizeUrl(url, { strict: true });
|
|
252
|
+
if (result !== 'safe') {
|
|
253
|
+
expect.fail(
|
|
254
|
+
`Expected the URL ${url} to be safe, but it was rejected: ${reason}`,
|
|
255
|
+
);
|
|
256
|
+
}
|
|
257
|
+
expect(safeUrl).to.eql(url);
|
|
258
|
+
expect(reason).to.be.undefined;
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
// to test URLs that are generally safe, but may lead to false-positives in strict mode
|
|
263
|
+
function shouldBeSafeInNonStrictMode(url) {
|
|
264
|
+
const { result, safeUrl, reason } = sanitizeUrl(url);
|
|
265
|
+
if (result !== 'safe') {
|
|
266
|
+
expect.fail(
|
|
267
|
+
`Expected the URL ${url} to be safe, but it was rejected: ${reason}`,
|
|
268
|
+
);
|
|
269
|
+
}
|
|
270
|
+
expect(safeUrl).to.eql(url);
|
|
271
|
+
expect(reason).to.be.undefined;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
// to test URLs that should be always dropped
|
|
275
|
+
function shouldBeDropped(url) {
|
|
276
|
+
{
|
|
277
|
+
const { result, safeUrl, reason } = sanitizeUrl(url);
|
|
278
|
+
expect(result).to.eql('dropped');
|
|
279
|
+
expect(safeUrl).to.eql(null);
|
|
280
|
+
expect(reason).to.be.a('string').that.is.not.empty;
|
|
281
|
+
}
|
|
282
|
+
{
|
|
283
|
+
const { result, safeUrl, reason } = sanitizeUrl(url, { strict: true });
|
|
284
|
+
expect(result).to.eql('dropped');
|
|
285
|
+
expect(safeUrl).to.eql(null);
|
|
286
|
+
expect(reason).to.be.a('string').that.is.not.empty;
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
// to test URLs that should be always truncated (or even dropped in strict mode)
|
|
291
|
+
function shouldBeTruncated(url) {
|
|
292
|
+
{
|
|
293
|
+
const { result, safeUrl, reason } = sanitizeUrl(url);
|
|
294
|
+
expect(result).to.eql('truncated');
|
|
295
|
+
expect(safeUrl).to.be.a('string').that.is.not.empty;
|
|
296
|
+
expect(safeUrl.endsWith(' (PROTECTED)'), 'ends with "(PROTECTED)"').to.be
|
|
297
|
+
.true;
|
|
298
|
+
expect(reason).to.be.a('string').that.is.not.empty;
|
|
299
|
+
}
|
|
300
|
+
{
|
|
301
|
+
const { result, safeUrl, reason } = sanitizeUrl(url, { strict: true });
|
|
302
|
+
expect(result).to.be.oneOf(['truncated', 'dropped']);
|
|
303
|
+
if (result === 'truncated') {
|
|
304
|
+
expect(safeUrl).to.be.a('string').that.is.not.empty;
|
|
305
|
+
expect(safeUrl.endsWith(' (PROTECTED)'), 'ends with "(PROTECTED)"').to
|
|
306
|
+
.be.true;
|
|
307
|
+
} else {
|
|
308
|
+
expect(safeUrl).to.eql(null);
|
|
309
|
+
}
|
|
310
|
+
expect(reason).to.be.a('string').that.is.not.empty;
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
// to test URLs that should be always truncated or dropped
|
|
315
|
+
function shouldBeDroppedOrTruncated(url) {
|
|
316
|
+
let originalResult;
|
|
317
|
+
{
|
|
318
|
+
const { result, safeUrl, reason } = sanitizeUrl(url);
|
|
319
|
+
expect(result).to.be.oneOf(['truncated', 'dropped']);
|
|
320
|
+
expect(safeUrl).to.not.eql(url);
|
|
321
|
+
expect(reason).to.be.a('string').that.is.not.empty;
|
|
322
|
+
originalResult = result;
|
|
323
|
+
}
|
|
324
|
+
{
|
|
325
|
+
const { result, safeUrl, reason } = sanitizeUrl(url, { strict: true });
|
|
326
|
+
if (originalResult === 'dropped' && result !== 'dropped') {
|
|
327
|
+
expect.fail(
|
|
328
|
+
'Expected the URL ${url} that was dropped in default mode to also be dropped in strict mode',
|
|
329
|
+
);
|
|
330
|
+
}
|
|
331
|
+
expect(result).to.be.oneOf(['truncated', 'dropped']);
|
|
332
|
+
expect(safeUrl).to.not.eql(url);
|
|
333
|
+
expect(reason).to.be.a('string').that.is.not.empty;
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
// to test URLs that should be truncated in strict mode
|
|
338
|
+
// (but may be accepted in non-strict mode)
|
|
339
|
+
function shouldBeTruncatedInStrictMode(url) {
|
|
340
|
+
{
|
|
341
|
+
const { result, safeUrl, reason } = sanitizeUrl(url, { strict: true });
|
|
342
|
+
expect(result).to.eql('truncated');
|
|
343
|
+
expect(safeUrl).to.be.a('string').that.is.not.empty;
|
|
344
|
+
expect(safeUrl.endsWith(' (PROTECTED)'), 'ends with "(PROTECTED)"').to.be
|
|
345
|
+
.true;
|
|
346
|
+
expect(reason).to.be.a('string').that.is.not.empty;
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
describe('should accept trivial URLs', function () {
|
|
351
|
+
[
|
|
352
|
+
'https://example.com/',
|
|
353
|
+
'https://www.ghostery.com/',
|
|
354
|
+
'https://de.wikipedia.org/',
|
|
355
|
+
].forEach((url) => {
|
|
356
|
+
it(`should accept URL: ${url}`, function () {
|
|
357
|
+
shouldBeSafe(url);
|
|
358
|
+
});
|
|
359
|
+
});
|
|
360
|
+
});
|
|
361
|
+
|
|
362
|
+
describe('should drop URLs with username and/or passwords', function () {
|
|
363
|
+
[
|
|
364
|
+
'https://user@example.com/',
|
|
365
|
+
'https://user@example.com/foo/bar',
|
|
366
|
+
'https://user:password@example.com/',
|
|
367
|
+
].forEach((url) => {
|
|
368
|
+
it(`should drop URL: ${url}`, function () {
|
|
369
|
+
shouldBeDropped(url);
|
|
370
|
+
});
|
|
371
|
+
});
|
|
372
|
+
});
|
|
373
|
+
|
|
374
|
+
describe('should drop URLs to localhost', function () {
|
|
375
|
+
[
|
|
376
|
+
'http://127.0.0.1/',
|
|
377
|
+
'http://127.0.0.1/some/local/app',
|
|
378
|
+
'http://localhost:8080/',
|
|
379
|
+
].forEach((url) => {
|
|
380
|
+
it(`should drop URL: ${url}`, function () {
|
|
381
|
+
shouldBeDropped(url);
|
|
382
|
+
});
|
|
383
|
+
});
|
|
384
|
+
});
|
|
385
|
+
|
|
386
|
+
describe('should drop URLs with non-standard HTTP ports', function () {
|
|
387
|
+
['http://myserver.test:1234/', 'https://www.myserver.test:5678/'].forEach(
|
|
388
|
+
(url) => {
|
|
389
|
+
it(`should drop URL: ${url}`, function () {
|
|
390
|
+
shouldBeDropped(url);
|
|
391
|
+
});
|
|
392
|
+
},
|
|
393
|
+
);
|
|
394
|
+
|
|
395
|
+
it('should allow port 80', function () {
|
|
396
|
+
shouldBeSafe('http://myserver.test:80/');
|
|
397
|
+
});
|
|
398
|
+
|
|
399
|
+
it('should allow port 443', function () {
|
|
400
|
+
shouldBeSafe('https://myserver.test:443/');
|
|
401
|
+
});
|
|
402
|
+
});
|
|
403
|
+
|
|
404
|
+
describe('should drop non-HTTP protocols', function () {
|
|
405
|
+
[
|
|
406
|
+
'ftp://example.test/',
|
|
407
|
+
'mailto:someone@example.com',
|
|
408
|
+
'file:///home/user/some-local-file.txt',
|
|
409
|
+
'data:text/plain;charset=UTF-8;page=21,the%20data:1234,5678',
|
|
410
|
+
'data:text/vnd-example+xyz;foo=bar;base64,R0lGODdh',
|
|
411
|
+
].forEach((url) => {
|
|
412
|
+
it(`should drop URL: ${url}`, function () {
|
|
413
|
+
shouldBeDropped(url);
|
|
414
|
+
});
|
|
415
|
+
});
|
|
416
|
+
});
|
|
417
|
+
|
|
418
|
+
describe('should drop URLs that leak extension IDs', function () {
|
|
419
|
+
[
|
|
420
|
+
'moz-extension://ad2fe927-3371-4319-9b32-1c9b3cdb53a0/',
|
|
421
|
+
'moz-extension://ad2fe927-3371-4319-9b32-1c9b3cdb53a0/foo/bar?x=1',
|
|
422
|
+
'chrome-extension://mlomiejdfkolichcflejclcbmpeaniij/app/templates/panel.html',
|
|
423
|
+
].forEach((url) => {
|
|
424
|
+
it(`should drop URL: ${url}`, function () {
|
|
425
|
+
shouldBeDropped(url);
|
|
426
|
+
});
|
|
427
|
+
});
|
|
428
|
+
});
|
|
429
|
+
|
|
430
|
+
describe('should drop URLs with extremly long hostnames', function () {
|
|
431
|
+
[
|
|
432
|
+
'https://aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.foo.test/',
|
|
433
|
+
'https://optsokzkgaqmvplqrcjfkgpnfxuluhmfaklxfvsfeyvwavsrqrhtvkvxhskjjraibwfzau.foo.test/',
|
|
434
|
+
'https://aaaaa.aaaaaaaaaaaa.aaaaaaaaaaaa.aaaaaaaaaaaa.aaaaaaaaaaaaaa.aaaaaaaaaa.foo.test/',
|
|
435
|
+
'https://optso.zkgaqmvplqrc.fkgpnfxuluhm.aklxfvsfeyvw.vsrqrhtvkvxhsk.jraibwfzau.foo.test/',
|
|
436
|
+
'https://aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.foo.test/bar?x=y',
|
|
437
|
+
'https://optso.zkgaqmvplqrc.fkgpnfxuluhm.aklxfvsfeyvw.vsrqrhtvkvxhsk.jraibwfzau.foo.test/bar?x=y',
|
|
438
|
+
'http://1couriersdeliveryservicesusanycnybostonmawashingtondcnewarknjct.1esamedaycourieranddeliveryserviceinnewyorknybostonmawashington.com/',
|
|
439
|
+
].forEach((url) => {
|
|
440
|
+
it(`should drop URL: ${url}`, function () {
|
|
441
|
+
shouldBeDropped(url);
|
|
442
|
+
});
|
|
443
|
+
});
|
|
444
|
+
});
|
|
445
|
+
|
|
446
|
+
describe('should drop URLs of onion services', function () {
|
|
447
|
+
[
|
|
448
|
+
'https://protonmailrmez3lotccipshtkleegetolb73fuirgj7r4o4vfu7ozyd.onion/',
|
|
449
|
+
'https://protonmailrmez3lotccipshtkleegetolb73fuirgj7r4o4vfu7ozyd.onion/login',
|
|
450
|
+
'https://www.nytimesn7cgmftshazwhfgzm37qxb44r64ytbb2dj3x62d2lljsciiyd.onion/',
|
|
451
|
+
].forEach((url) => {
|
|
452
|
+
it(`should drop URL: ${url}`, function () {
|
|
453
|
+
shouldBeDropped(url);
|
|
454
|
+
});
|
|
455
|
+
});
|
|
456
|
+
});
|
|
457
|
+
|
|
458
|
+
describe('should drop URLs that contain geo-coordinates', function () {
|
|
459
|
+
[
|
|
460
|
+
'https://www.google.com/maps/dir//Spring,+TX+77373/@30.095431,-95.6501944,10z/data=!4m18!1m8!3m7!1s0x8640ccc646dfdb4b:0x496129fbe4b11b29!2sSpring,+TX+77373!3b1!8m2!3d30.0799405!4d-95.4171601!16zL20vMDEwMnFx!4m8!1m0!1m5!1m1!1s0x8640ccc646dfdb4b:0x496129fbe4b11b29!2m2!1d-95.4171601!2d30.0799405!3e0?entry=ttu',
|
|
461
|
+
'https://www.google.com/maps/search/correios+curitiba+joao+negrao+telefone/@-25.4393609,-49.2639141,17z/data=!3m1!4b1?entry=ttu',
|
|
462
|
+
'https://www.google.com/maps/dir//London+Stansted+Airport+(STN),+Bassingbourn+Rd,+Stansted+CM24+1QW,+United+Kingdom/@51.8863747,0.2387409,17z/data=!3m1!5s0x47d88fb4f87490e3:0x165d2ba117eb3309!4m17!1m7!3m6!1s0x487604b8a52a1bb7:0x30a4d0976b352648!2sLondon+Stansted+Airport!8m2!3d51.8863747!4d0.2413158!16zL20vMGhjc2g!4m8!1m0!1m5!1m1!1s0x487604b8a52a1bb7:0x30a4d0976b352648!2m2!1d0.2413158!2d51.8863747!3e2?entry=ttu',
|
|
463
|
+
|
|
464
|
+
'https://www.google.com/maps/search/somesearch+querythat+may+point+tosomething/@-33.6278509,-39.2539141,17z/data=!3m1!4b1?entry=ttu',
|
|
465
|
+
'https://www.google.com/maps/place/Klinikum+rechts+der+Isar+der+Technischen+Universit%C3%A4t+M%C3%BCnchen/@48.1379612,11.5936122,16z/data=!3m1!5s0x479e75825cd00d45:0xd2ae74823f848e47!4m9!1m2!2m1!1sfriedensengel!3m5!1s0x479e7582085e4a3f:0xa3dffab473c868fe!8m2!3d48.1369622!4d11.5987872!16s%2Fm%2F027drtc?entry=ttu',
|
|
466
|
+
'https://www.google.com/maps/dir/54.7925405,9.4078768/47.664786,12.4509673/@51.0971126,5.652494,6z/data=!3m1!4b1!4m2!4m1!3e1?entry=ttu',
|
|
467
|
+
'https://www.google.com/maps/dir/54.7925405,9.4078768/47.664786,12.4509673/@52.1471636,10.5343305,15z/am=t/data=!4m6!4m5!3e2!6m3!1i0!2i0!3i292?entry=ttu',
|
|
468
|
+
'https://www.google.sk/maps/@48.7418457,19.1206357,17z',
|
|
469
|
+
'https://www.google.sk/maps/@48.7418457,19.1206357,17z?hl=sk',
|
|
470
|
+
|
|
471
|
+
'https://earth.google.com/web/search/Friedensengel,+Munich/@48.13744933,11.57593029,543.01680528a,198.36981833d,35y,56.31537172h,63.30010268t,0r/data=CigiJgokCbWQ8mGJyElAEaUBKqw4vUlAGbBzvV65kbq_IUBAl4LnwMe_',
|
|
472
|
+
'https://earth.google.com/web/@52.51681316,13.37854689,36.02282027a,264.60462944d,35y,-85.81195214h,67.15515115t,0r/data=ClQaUhJMCiUweDQ3YTg1MWM2NTVmMjA5ODk6MHgyNmJiZmI0ZTg0Njc0YzYzGbNgPUkVQkpAIQMjL2tiwSpAKhFCcmFuZGVuYnVyZ2VyIFRvchgCIAE',
|
|
473
|
+
|
|
474
|
+
'https://www.bing.com/maps?osid=e0523a41-9eb1-41f0-b11c-82e4df1dd657&cp=52.216391~20.965831&lvl=14.48&pi=0&imgid=326a2db2-988d-4b37-b7ee-c6171118f522&v=2&sV=2&form=S00027',
|
|
475
|
+
'https://www.bing.com/maps?osid=e0523a41-9eb1-41f0-b11c-82e4df1dd657&cp=52.217702%7E20.975582&lvl=17.1&imgid=326a2db2-988d-4b37-b7ee-c6171118f522&v=2&sV=2&form=S00027',
|
|
476
|
+
|
|
477
|
+
'https://yandex.com/maps/org/untersbergstra_e/186631167268/?ll=11.591015%2C48.108343&z=15',
|
|
478
|
+
'https://yandex.com/maps/99/munich/?ll=11.513703%2C48.114106&mode=routes&rtext=48.088307%2C11.645045~48.116376%2C11.502502&rtt=auto&ruri=~&z=13',
|
|
479
|
+
|
|
480
|
+
'https://map.baidu.com/dir/%E6%B9%96%E5%8C%97%E7%9C%81%E8%8D%86%E5%B7%9E%E5%B8%82%E7%9B%91%E5%88%A9%E5%B8%82/%E6%B9%96%E5%8C%97%E7%9C%81%E6%AD%A6%E6%B1%89%E5%B8%82%E6%B1%9F%E5%A4%8F%E5%8C%BA/@12583662.48,3523702.875,10z?querytype=bt&c=1713&sn=1$$$$12549545.96,3485268.75$$%E6%B9%96%E5%8C%97%E7%9C%81%E8%8D%86%E5%B7%9E%E5%B8%82%E7%9B%91%E5%88%A9%E5%B8%82$$0$$$$&en=1$$$$12708649.959999993,3508820.7624418424$$%E6%B9%96%E5%8C%97%E7%9C%81%E6%AD%A6%E6%B1%89%E5%B8%82%E6%B1%9F%E5%A4%8F%E5%8C%BA$$0$$$$&sc=1713&ec=1713&pn=0&rn=5&exptype=dep&exptime=2024-03-04%2017:24&version=5&da_src=shareurl',
|
|
481
|
+
|
|
482
|
+
'https://www.openstreetmap.org/search?whereami=1&query=48.13664%2C11.57526#map=19/48.13664/11.57526',
|
|
483
|
+
'https://www.openstreetmap.org/directions?engine=fossgis_osrm_car&route=48.13697%2C11.57475%3B48.13758%2C11.57521#map=19/48.13635/11.57565',
|
|
484
|
+
|
|
485
|
+
'https://citymapper.com/london/superrouter?end=51.5112932884513,-0.117667260852045&eaddr=Somerset House, Strand, London, WC2R 1LA',
|
|
486
|
+
'https://citymapper.com/london/superrouter?end=51.5112932884513,-0.117667260852045&eaddr=Somerset%20House,%20Strand,%20London,%20WC2R%201LA',
|
|
487
|
+
'https://www.seeker.info/index.php/location/fr-DE/Hambourg,_Allemagne@53.5510846,9.99368179999999/theme/18514__Toilettes_publiques/detail/osm_node_264990234__Europa Passage?lang=fr',
|
|
488
|
+
'https://www.timeanddate.com/sun/@12.5781879602632,122.268390655518',
|
|
489
|
+
'http://busqueda.lavoztx.com/en/garden-grove-ca/local/.a_5.c_bingo-halls/?p=2&coords=33.773905300000003,-117.941447699999998',
|
|
490
|
+
].forEach((url) => {
|
|
491
|
+
it(`should drop URL: ${url}`, function () {
|
|
492
|
+
shouldBeTruncated(url);
|
|
493
|
+
});
|
|
494
|
+
});
|
|
495
|
+
});
|
|
496
|
+
|
|
497
|
+
describe('should truncate long URLs', function () {
|
|
498
|
+
it('should truncate URLs by preserving only the hostname', function () {
|
|
499
|
+
const url =
|
|
500
|
+
'https://www.example.com/foo-106783?cep=C6SNdZ-JdYgfxMe-Ew0e8PbCNBIeJNwcVsgDmQGentDzy4rUEIYTxZt6797urbzd-X5xoFI8QMYyZkHfIevGn3BMV0PZ2myYl6UB65r7iChjOeqLXibqpfGtFNt55Pe68Bi1qnbbHfJ10nNDib54gnog3PEKDMC6G95iU8o7wKTCIHPsL52Vs1pQrdh8eB_ETPDzRCPmJ-QIOKfdBb3RmXkC7EEAO3nG7dhHR3sD60tlU9c-O9mKA73w3p0Er9HEFnibX8QVkoostBEZob5WtfiIgTdiYFWtc0jnBtJQdfRiYbForVoYlkm6eUReWgKRGxmCr8tU6p9GANbZf8QMRyFp0LnK9FaPi3Ti2J99ZMKKxCsCrczjz-0lE-bOtnpAcQ1Kq3CFne4T4_PfF68UhJ3QMQlZK5592M_fOgeCem6g0bDRfWRhva4HV-1PY2ccp4i_olg3mnJhQn1NWLLgOVMDKgWM4zneB_SlBWpZ0FjIIqU6mpAtmx33x6vF9A5qQWKginNWJETV3BZvspcVU47wBxdIMmHPwxIFuVcu1uoS1u_HmEVbsmrIPzCqgmej_Rz0zIMdpB_CUCI6gVHLCUmLhtb0rYCPfRT71L25idEyOOzuhLJd-caBlQWR3D_d54suQZ0YtPk_VtMIUtejmNOVkNJ_XemssaWb0flUKDuypAqogHwhT3GbGC3V_O-AlX1aO92nfo1dP46CMGT9lg8GizI-NRic1_NLy2hMkwmrhtkZjdvqgc-gRLAryB8ayHKEFy-ggfqaK0Dz0lrGgBcEPslee84q6ZQ6DVzkViq-razGQce5BTpD1ee8IxRnKgtxvQLK_i4qfcXLP9xP0vKmg7NjzKc0bre4eG8JiY8EoareMOwEdCb72gWyPOwM9MwR4Q4E8_N93qWRpBfHN_0bKrR9t-OunSr1kCW65qBylJa_bvpJ5UztYXQ8ijbE0gLU4TANyekzY-eYVcXues3dDr3Uso9RNA2BxKwiS7qE8sdI1h9yIHt8JAv3jWAwqvuD6Htv4Fnw2ZKgdYB--it9jYJEAId1SVyMyWjtySpTzYvsf1XDXxl2uOEOHHp67p39xE4XA4fuPBuAhTef9YZgP4qVIPhoTXywyjMQKP0uF09MoOuKCaX4yWNRzTe-3jEA6rSV9KrffnCzbS0UHSLy6zkNnUTulO_rOZ1HLDtslljN7iBNpBeBFg87qAMu0_-h2tFfblBnzcIYAFxfVRPS5Si-RWsaU62yS9R354q9ugncvBBzSHceVLcAMa6-4yvK8qAplqfJXmH8tNz5q6fVMhkxbl-JlNLFOUW0a-mhLglQCl_vr3twJ5HCOnvdiOq2GU3KqUBbIG63ZtNuw-ai8BHIYh1X49gW-s3fgQAbvihJWt3Nuc4wzfQg0KLQE4NQ9c-yYRtEh2PnocC0CHzvgapVQeiuW2e8d7-sJvFELPuCitEQbRBSTvVMEIjiCqhwtGNn5uQw5bvVN2i0ysGw3ebmb-Vg91y965jo0FEmAArJ4OwswS-_dXBYX6lvUZ688yaKPPEzcpgiEyXa-k4mFz60IVjFQROoRmYOZbbg9_PBo5mj2SjMB2-EOvp4_YV8h2JDNk7X7a-AcEUE60VaJkWE3SBcS45VsiAT8-y2Lkyfuq-lbCpBLw1gT1Mm6cdbqCaZ3hX7C_doCBjh3lnQNfCkDtEqUWa1xHULbaDDxxRzZb9R13Ua3YVOJF-DY0KFWxrMgBA_NjRosJEz0Lcji7LN9wmQktyoO5nZrAdQgtogMaiByqMNhjE8agj7FO8S2qItbCDiRg0pbKnes6bTBCw7_y1putoG31uTKcd6Z72Tn7kFyYib8eH_1N8Y';
|
|
501
|
+
expect(sanitizeUrl(url).safeUrl).to.eql(
|
|
502
|
+
'https://www.example.com/ (PROTECTED)',
|
|
503
|
+
);
|
|
504
|
+
});
|
|
505
|
+
|
|
506
|
+
[
|
|
507
|
+
'https://www.example.com/foo-106783?cep=C6SNdZ-JdYgfxMe-Ew0e8PbCNBIeJNwcVsgDmQGentDzy4rUEIYTxZt6797urbzd-X5xoFI8QMYyZkHfIevGn3BMV0PZ2myYl6UB65r7iChjOeqLXibqpfGtFNt55Pe68Bi1qnbbHfJ10nNDib54gnog3PEKDMC6G95iU8o7wKTCIHPsL52Vs1pQrdh8eB_ETPDzRCPmJ-QIOKfdBb3RmXkC7EEAO3nG7dhHR3sD60tlU9c-O9mKA73w3p0Er9HEFnibX8QVkoostBEZob5WtfiIgTdiYFWtc0jnBtJQdfRiYbForVoYlkm6eUReWgKRGxmCr8tU6p9GANbZf8QMRyFp0LnK9FaPi3Ti2J99ZMKKxCsCrczjz-0lE-bOtnpAcQ1Kq3CFne4T4_PfF68UhJ3QMQlZK5592M_fOgeCem6g0bDRfWRhva4HV-1PY2ccp4i_olg3mnJhQn1NWLLgOVMDKgWM4zneB_SlBWpZ0FjIIqU6mpAtmx33x6vF9A5qQWKginNWJETV3BZvspcVU47wBxdIMmHPwxIFuVcu1uoS1u_HmEVbsmrIPzCqgmej_Rz0zIMdpB_CUCI6gVHLCUmLhtb0rYCPfRT71L25idEyOOzuhLJd-caBlQWR3D_d54suQZ0YtPk_VtMIUtejmNOVkNJ_XemssaWb0flUKDuypAqogHwhT3GbGC3V_O-AlX1aO92nfo1dP46CMGT9lg8GizI-NRic1_NLy2hMkwmrhtkZjdvqgc-gRLAryB8ayHKEFy-ggfqaK0Dz0lrGgBcEPslee84q6ZQ6DVzkViq-razGQce5BTpD1ee8IxRnKgtxvQLK_i4qfcXLP9xP0vKmg7NjzKc0bre4eG8JiY8EoareMOwEdCb72gWyPOwM9MwR4Q4E8_N93qWRpBfHN_0bKrR9t-OunSr1kCW65qBylJa_bvpJ5UztYXQ8ijbE0gLU4TANyekzY-eYVcXues3dDr3Uso9RNA2BxKwiS7qE8sdI1h9yIHt8JAv3jWAwqvuD6Htv4Fnw2ZKgdYB--it9jYJEAId1SVyMyWjtySpTzYvsf1XDXxl2uOEOHHp67p39xE4XA4fuPBuAhTef9YZgP4qVIPhoTXywyjMQKP0uF09MoOuKCaX4yWNRzTe-3jEA6rSV9KrffnCzbS0UHSLy6zkNnUTulO_rOZ1HLDtslljN7iBNpBeBFg87qAMu0_-h2tFfblBnzcIYAFxfVRPS5Si-RWsaU62yS9R354q9ugncvBBzSHceVLcAMa6-4yvK8qAplqfJXmH8tNz5q6fVMhkxbl-JlNLFOUW0a-mhLglQCl_vr3twJ5HCOnvdiOq2GU3KqUBbIG63ZtNuw-ai8BHIYh1X49gW-s3fgQAbvihJWt3Nuc4wzfQg0KLQE4NQ9c-yYRtEh2PnocC0CHzvgapVQeiuW2e8d7-sJvFELPuCitEQbRBSTvVMEIjiCqhwtGNn5uQw5bvVN2i0ysGw3ebmb-Vg91y965jo0FEmAArJ4OwswS-_dXBYX6lvUZ688yaKPPEzcpgiEyXa-k4mFz60IVjFQROoRmYOZbbg9_PBo5mj2SjMB2-EOvp4_YV8h2JDNk7X7a-AcEUE60VaJkWE3SBcS45VsiAT8-y2Lkyfuq-lbCpBLw1gT1Mm6cdbqCaZ3hX7C_doCBjh3lnQNfCkDtEqUWa1xHULbaDDxxRzZb9R13Ua3YVOJF-DY0KFWxrMgBA_NjRosJEz0Lcji7LN9wmQktyoO5nZrAdQgtogMaiByqMNhjE8agj7FO8S2qItbCDiRg0pbKnes6bTBCw7_y1putoG31uTKcd6Z72Tn7kFyYib8eH_1N8Y',
|
|
508
|
+
'https://www.ebay.com/itm/163578162904?_trkparms=aid=1110006&algo=HOMESPLICE.SIM&ao=1&asc=20200818143132&meid=c742ec041c2a472fb37e5619938525f4&pid=101198&rk=4&rkt=12&b=1&sd=183714353142&itm=163578162904&pmt=1&noa=0&pg=2047675&algv=SimplAMLCvipPairwiseWebWithBBEV2bDemotion&brand=GPR&_trksid=p2047675.c101198.m1985&amdata=cksum:163578162904c742ec041c2a472fb37e5619938525f4|enc:AQAFAAACEO1gRbE4sAI38m6EZRpzbYHt9+yQk5vBehmhugFgnd17OkYn0W555gLuJgoGFdYmC+BHEJ3b1mSo549wwtufJLAdy0dMBi9iAdXKeADjcgjm71kyFYVvAgt/0a+xOvYAqJMv2z3Ygpiux3Ba2KyLymWzBtI8d0dJFza/2IQKhhiibQtAh8AGWxt3i5/GcPW6d8+P36eLlNPC14uobuNPxmA7pxRunrP4xwNkQ7qod9RWebQ4+iBVr8/OBmp8ulmR+toSAD4WEySHQf62yBtANWEAvc7s77XgdgzjIhcxBMz5nBrwEe3ZPwVMiit6Kcnwg5S9bxJchrGh74nQTH3HwEOYN1qghIRC8Me3cOsdF4LFEeZtxiPHvjizNX2RO9+jnwluy0wq7dZeZiM+doqTSxbsh78ah0ZctrGMrMYO3OhY5ptxXsxL0eL5flyRRsXyNzKO/0EtLGzuwZd87pu0/c/B6mI4/JAqfs2+sFpmVW2q+/GnrgaTs0iXK4YdwdSOXd5cn1HTvp2cL18aedatm29/QsP0ZSheuHQAKZCASY4rASb6H1XaYApfOLa0yzU4fwVWCEoTc+5mO55+UxUYwZ0ZX+NWRCrQEjCHkdY+qfIs2JDvCpXQC0PTr571yWFgcQTv3RwYBZlHIqC5aTEYKAVeNQm5HP0udq9Q/pq2uASBXqYldCNh2M0bI0MsvuvFfg==|ampid:PL_CLK|clp:2047675&epid=10029966056',
|
|
509
|
+
'https://pulsar.ebay.de/plsr/mpe/0/SAND/9?pld=%5B%7B%22ef%22%3A%22SAND%22%2C%22ea%22%3A%223PADS%22%2C%22pge%22%3A2367355%2C%22plsUBT%22%3A1%2C%22app%22%3A%22Sandwich%22%2C%22callingEF%22%3A%22SAND%22%2C%22difTS%22%3A60000%2C%22eventOrder%22%3A0%2C%22scandal_imp%22%3A%22meid%3A01HF9D6M05QAY12A7PXJCQC3DA%2Cplid%3A100562%2Cscorid%3A01HF9D5N3RHX8Y5JHFCN6A89J2%2Cprvdr%3Ahybrid%2Cafs%3A1700049145742%2Cade%3A0%7Cmeid%3A01HF9D6M2EBTS39V0893V2KVS1%2Cplid%3A100938%2Cscorid%3A01HF9D5N3RSYG09WFT7RWTDNC0%2Cprvdr%3Ahybrid%2Cafs%3A1700049145804%2Cade%3A0%22%7D%2C%20%7B%22ef%22%3A%22SAND%22%2C%22ea%22%3A%223PADS%22%2C%22pge%22%3A2367355%2C%22plsUBT%22%3A1%2C%22app%22%3A%22Sandwich%22%2C%22callingEF%22%3A%22SAND%22%2C%22difTS%22%3A29996%2C%22eventOrder%22%3A1%2C%22scandal_imp%22%3A%22meid%3A01HF9D7H9X7EC48AM748JF6Q4E%2Cplid%3A100562%2Cscorid%3A01HF9D6M05WNWMZ7GGSXQX7RAD%2Cprvdr%3Ahybrid%2Cafs%3A1700049175742%2Cade%3A0%7Cmeid%3A01HF9D7HBFS4EGX20SGQ0RW8SS%2Cplid%3A100938%2Cscorid%3A01HF9D6M2EDGBZG3Y2PCZ1722Q%2Cprvdr%3Ahybrid%2Cafs%3A1700049175804%2Cade%3A0%22%7D%5D',
|
|
510
|
+
'https://www.skyscrapercity.com/showthread.php?t=1674676:@0.119399:0.238103:0.547455:0.238103:0.547455:0.222531:0.119399:0.222531:0.000000:0.000000:0.000000:0.000000:0.000000:0.000000:0.000000:0.000000:0.000000:0.000000:0.000000:0.000000:0.000000:0.000000:0.000000:0.000000:0.000000:0.000000:0.000000:0.000000:0.000000:0.000000:0.000000:0.000000:0.000000:0.000000:0.000000:0.000000:0.000000:0.000000:0.000000:0.000000:0.000000:0.000000:0.000000:0.000000:0.000000:0.000000:0.000000:0.000000:0.000000:0.000000:0.000000:0.000000:0.000000:0.000000:0.000000',
|
|
511
|
+
].forEach((url) => {
|
|
512
|
+
it(`should truncated: ${url}`, function () {
|
|
513
|
+
shouldBeTruncated(url);
|
|
514
|
+
});
|
|
515
|
+
});
|
|
516
|
+
|
|
517
|
+
[
|
|
518
|
+
'https://www.medimops.de/chip-huyen-designing-machine-learning-systems-an-iterative-process-for-production-ready-applications-taschenbuch-M01098107969.html?variant=LibriNew',
|
|
519
|
+
'https://www.walmart.com/ip/Purina-ONE-Plus-Natural-Classic-Ground-Healthy-Puppy-Dog-Food-Wet-Lamb-and-Long-Grain-Rice-Entree-13-oz-Can/10295565?wl13=2123&selectedSellerId=0',
|
|
520
|
+
'https://www.worten.pt/informatica-e-acessorios/computadores/computadores-portateis/portatil-asus-f415ea-51alhdcb2-14-intel-core-i5-1135g7-ram-8-gb-512-gb-ssd-intel-iris-xe-graphics-7553568',
|
|
521
|
+
'https://www.oskab.com/cuisine/plan-de-travail-et-credence/plan-de-travail-pret-a-poser/42960-plan-de-travail-cuisine-n311-decor-marbre-noir-stratifie-chant-coordonne-l300-x-l62-x-e38-cm-planeko.html',
|
|
522
|
+
'https://www.walmart.com/ip/Auto-Drive-Lightning-to-USB-A-Durable-Braided-Data-Sync-and-Charging-Cable-Cord-3-feet-Compatible-with-iPhone-12-11-SE-8-7-6-Made-by-Luxshare/351215507?wl13=4166&selectedSellerId=0',
|
|
523
|
+
'https://www.bestbuy.ca/en-ca/product/motiongrey-standing-desk-height-adjustable-electric-motor-sit-to-stand-desk-computer-for-home-and-office-black-frame-55x24-tabletop-included-only-at-best-buy/15766135?cmp=seo-15766135',
|
|
524
|
+
'https://www.darty.com/nav/achat/sports_loisirs/gyropode/gyropode/evercross_evercross_hoverboard_overboard_gyropode_tout_terrain_8_5_self_balancing_scooter_hummer_suv_bluetooth_app_700w_camouflege_hoverkart_kart_camouflage__MK461561901.html?ofmp=52559053',
|
|
525
|
+
'https://www.medion.com/de/shop/p/notebook-zubehoer-medion-life-e83265-usb-headset-stereo-kopfhoerer-fuer-ein-perfektes-klangerlebnis-integriertes-mikrofon-mit-glasklarer-tonaufnahme-pratkischer-lautstaerkeregler-am-kabel-leicht-und-bequem-plug--play-fuer-pcs-und-notebooks-50066287A1',
|
|
526
|
+
'https://www.elektronik-star.de/Haushalt-Wohnen/Kuechengeraete/Kuechenhelfer-Kuechenaccessoires/Glaeser-Becher/DUOS-doppelwandiges-Glas-Thermoglas-80-ml-Trinkglas-Espressoglas-Teeglas-Shotglas-fuer-heisse-und-kalte-Getraenke-Borosilikatglas-hitze-und-kaeltebestaendig-handgemacht-spuelmaschinenfest-Schwebe-Effekt-4er-Set.html',
|
|
527
|
+
'https://business.currys.co.uk/catalogue/computing/servers-networking/networking/modem-routers/startech-com-m-2-pci-e-nvme-to-u-2-sff-8639-adapter-not-compatible-with-sata-drives-or-sas-controllers-for-m-2-pcie-nvme-ssds-pcie-m-2-drive-to-u-2-host-adapter-m2-ssd-converter-u2m2e125-interface-adapter-m-2-card-u-2/P272563P?cidp=Froogle&affiliate=ppc',
|
|
528
|
+
'http://britain.desertcart.com/products/484923669-bezgar-tc141-toy-grade-1-14-scale-remote-control-car-all-terrains-electric-toy-off-road-rc-truck-remote-control-monster-truck-for-kids-boys-3-4-5-6-7-8-with-rechargeable-battery-bezgar-remote-control-construction-excavator-rc-toys-with-2-rechargeable-batteries-for-kids-age-6-7-8-9-10-11-rc-construction-truck-vehicle-toys-with-light-for-boys-and-girls-tk181-bezgar-hs181-hobby-grade-1-18-scale-remote-control-trucks-4wd-top-speed-35-km-h-all-terrains-off-road-short-course-rc-truck-waterproof-rc-car-with-2-rechargeable-batteries-for-kids-and-adults-bezgar-hm161-hobby-grade-1-16-scale-remote-control-truck-4wd-high-speed-40-kmh-all-terrains-electric-toy-off-road-rc-vehicle-car-crawler-with-2-rechargeable-batteries-for-boys-kids-and-adults',
|
|
529
|
+
].forEach((url) => {
|
|
530
|
+
it(`should allow long, but safe URLs: ${url}`, function () {
|
|
531
|
+
shouldBeSafe(url);
|
|
532
|
+
});
|
|
533
|
+
});
|
|
534
|
+
|
|
535
|
+
[
|
|
536
|
+
'https://www.amazon.de/SUNNYBAG-Solar-Modul-umweltfreundlich-Solar-Energie-Ultra-leicht/dp/B08FRL5G5S',
|
|
537
|
+
].forEach((url) => {
|
|
538
|
+
it(`should allow long, but safe URLs (strict mode exceptions): ${url}`, function () {
|
|
539
|
+
shouldBeSafeInNonStrictMode(url);
|
|
540
|
+
});
|
|
541
|
+
});
|
|
542
|
+
});
|
|
543
|
+
|
|
544
|
+
describe('should truncate login specific URLs', function () {
|
|
545
|
+
[
|
|
546
|
+
'https://access.ing.de/delogin/w/login?t=https://access.ing.de/delogin/oauth/authorize?response_type%3Dcode%26client_id%3Dibbr%26scope%3Dbanking%2520postlogin%2520tpa%2520openid%26state%3DAXHw4viZF1ntx4i3gOcflIUKUK80Yix3Hr5LNsb0j0I%253D%26redirect_uri%3Dhttps://banking.ing.de/app/login/oauth2/code/ibbr%26nonce%3D9WjJS-aqnwAoAFd8fF4t5nNLuO-DsPA0ql-oKMGZ6zo%26claims%3D%257B%2522id_token%2522%253A%257B%2522customer_number%2522%253A%257B%2522essential%2522%253Atrue%257D%252C%2522partner_number%2522%253A%257B%2522essential%2522%253Atrue%257D%252C%2522last_login%2522%253A%257B%2522essential%2522%253Atrue%257D%252C%2522authentication_means%2522%253A%257B%2522essential%2522%253Atrue%257D%257D%257D',
|
|
547
|
+
'https://web.verimi.de/dipp/api/authenticate?login_challenge=498830e1f9734aebab6f382f673a20e5',
|
|
548
|
+
'https://accounts.google.com/signin/v2/usernamerecovery?continue=https%3A%2F%2Fgroups.google.com%2Fmy-groups&dsh=S285380746%3A1697710203082833&flowEntry=ServiceLogin&flowName=GlifWebSignIn&followup=https%3A%2F%2Fgroups.google.com%2Fmy-groups&ifkv=AVQVeyyeWVx_JoNaqej1zdzdZjDsJ1zQCgD0KdudwHwmez4dVJkWw_4bZVCCj46vLQVUVJGrBIxj&osid=1&theme=glif',
|
|
549
|
+
'https://accounts.google.com/v3/signin/identifier?continue=https%3A%2F%2Fwww.youtube.com%2Fsignin%3Faction_handle_signin%3Dtrue%26app%3Ddesktop%26hl%3Den%26next%3Dhttps%253A%252F%252Fwww.youtube.com%252F&ec=65620&hl=en&ifkv=AVQVeyyBkkwVyKEUa4Ul-Mll2WwmLVdi14ivGA8Cyxy2zYPVY1nAWoGydpfvNuPwgbFGJB9QrlpO&passive=true&service=youtube&uilel=3&flowName=GlifWebSignIn&flowEntry=ServiceLogin&dsh=S1006818886%3A1697723402009676&theme=glif',
|
|
550
|
+
'https://accounts.google.com/v3/signin/identifier?continue=https%3A%2F%2Fgroups.google.com%2Fmy-groups&followup=https%3A%2F%2Fgroups.google.com%2Fmy-groups&ifkv=AVQVeyyBm7cgqI8WYA9rOCycOcMyWoz7q8f1d0PTs9qu6Xj7evUrAr2u1DvlW9XklbfNlH4B324E&osid=1&passive=1209600&flowName=GlifWebSignIn&flowEntry=ServiceLogin&dsh=S285380746%3A1697710203082833&theme=glif',
|
|
551
|
+
'https://access.ing.de/delogin/w/login?x=sym2BPHMFmqV2hYUXnMw-YbrjfmV2Rsq2JfGZpNH1SnjUKBT1RYcA4A&t=https://access.ing.de/delogin/oauth/authorize%3Fresponse_type%3Dcode%26client_id%3Dibbr%26scope%3Dbanking%2520postlogin%2520tpa%2520openid%26state%3DAXHw4viZF1ntx4i3gOcflIUKUK80Yix3Hr5LNsb0j0I%253D%26redirect_uri%3Dhttps://banking.ing.de/app/login/oauth2/code/ibbr%26nonce%3D9WjJS-aqnwAoAFd8fF4t5nNLuO-DsPA0ql-oKMGZ6zo%26claims%3D%257B%2522id_token%2522%253A%257B%2522customer_number%2522%253A%257B%2522essential%2522%253Atrue%257D%252C%2522partner_number%2522%253A%257B%2522essential%2522%253Atrue%257D%252C%2522last_login%2522%253A%257B%2522essential%2522%253Atrue%257D%252C%2522authentication_means%2522%253A%257B%2522essential%2522%253Atrue%257D%257D%257D',
|
|
552
|
+
'https://www.facebook.com/recover/initiate/?privacy_mutation_token=eyJ0eXBlIjowLCJjcmVhdGlvbl90aW1lIjoxNjk3NzEyMTMyLCJjYWxsc2l0ZV9pZCI6MzgxMjI5MDc5NTc1OTQ2fQ==&ars=facebook_login',
|
|
553
|
+
'https://www.facebook.com/login/identify/?ctx=recover&ars=facebook_login&from_login_screen=0#',
|
|
554
|
+
'https://signon.ghostery.com/en/password/forgot?redirect=https%3A%2F%2Faccount.ghostery.com%2Fen%2F',
|
|
555
|
+
'https://signin.aws.amazon.com/signin?redirect_uri=https%3A%2F%2Fconsole.aws.amazon.com%2Fconsole%2Fhome%3FhashArgs%3D%2523%26isauthcode%3Dtrue%26nc2%3Dh_ct%26src%3Dheader-signin%26state%3DhashArgsFromTB_eu-north-1_7bbe8829a3606007&client_id=arn%3Aaws%3Asignin%3A%3A%3Aconsole%2Fcanvas&forceMobileApp=0&code_challenge=LfgbfGbtRHU3oaW7r8IvAWwD2OYiD-yJqcfaXtAijew&code_challenge_method=SHA-256',
|
|
556
|
+
'https://panel.bunny.net/user/login/verifycode?ReturnUrl=',
|
|
557
|
+
'https://panel.bunny.net/user/logout',
|
|
558
|
+
'https://www.faz.net/mein-faz-net/?redirectUrl=%2Faktuell%2F',
|
|
559
|
+
'https://account.booking.com/sign-in?op_token=LvIxMDI1yXO0RvfKdo4gV2Seyld5HAi1IH5pM7YyWZGVXHZ9dQcxnji0EFf9yUF1nUG0Op8lEHN9njKaMj8xy2iaEp3uh21xhQ8byH5ayUFshA8xnA9xMDI1yZ8pEDF9nj5qjTSIno9XkQdIHDG3niFrMiY7WUSFE9GsnlN0EIi5CHs9dUcQkKK2N19DVbd7GoFeVX1tkQNEVoc3IKLpVKSuD9S5D2ZBKQMlG2fpEH8YdlNtVZiiVKSET7dcTH8Tn13FdlcDHLdoKudSh1ZXEIElD7ZfkUo1Go3yFAEITbwgV9IWEjctTj8CWIwfMi8KOIZPFiiNhX9eI7YSNiTghuiiKLi5IQdsFoISdWSVnQsiGj8SViRtd7conANNNLe7NQ8jdjFUF2cqOHgEVKEFHogtWDwSVLNaHDZoyKIWTogoMIYKdHZwhQsmdQwKFWM2diEEVuZiNLL8BjI3VbYyT1o2VH3VkIiMHjgmF7ceM2t3h9wDFjsyHLiwEiL8JKPLM28oEVfwXP6PLuX-r_Ob6dPjCvYXRZmdu6aqYwPYLUFpMDEihQgini8fEHZoEDP',
|
|
560
|
+
'https://chat.openai.com/auth/login',
|
|
561
|
+
'https://auth0.openai.com/u/login/identifier?state=oWEi8YOHNHjyQ8Cyr3OsZ3jUH3QHXHQsIsjaPI1WLIxLCUcEjbEpt5QpbHCyeqDorS3ur8jxrgD9bUXCTGQbLQy7zqjwb83nUEOwKfcTUEysrf3BefxfDJoLP8cXi8DxCDmdQVKWYUDlCXB8Q81IYJKLLXQpzHy5bGQEDJyMrsCAjBe',
|
|
562
|
+
'https://auth0.openai.com/u/mfa-otp-challenge?state=pRHj6MZWGSpWY5GGMSqbdaqaq414GYZHW6GVdrqQUvqDdSpuwRHfhF1cPM1pqYVjWJ94dJNpqFJaqFrv6MO1JarWmBs5Y6nnwHpLY4WhMHpWw69nVBXiWaV7AcNhU3NadJAWCHVvMvraPcUbNrqtGSp4Aav1ekr9q6g1VAV9A686MYVB',
|
|
563
|
+
'https://www.otto.de/user/login?uri=/myaccount/dashboard?entryPoint%3DloginArea&tk=-109064015',
|
|
564
|
+
'https://accounts.google.com/v3/signin/identifier?continue=https%3A%2F%2Fdocs.google.com%2Fspreadsheets%2Fd%2F85ZW1T2ORppdfp23J8Ff8uzBM_s1AxUk4j2EjEjpUCKY%2Fedit%3Fskip_itp2_check%3Dtrue&followup=https%3A%2F%2Fdocs.google.com%2Fspreadsheets%2Fd%2F85ZW1T2ORppdfp23J8Ff8uzBM_s1AxUk4j2EjEjpUCKY%2Fedit%3Fskip_itp2_check%3Dtrue&ifkv=AVQVeyz9TNpWfqpigNtYCi6bils8e4UV1vVMccyjcYtaeCwWd13k7rhQK8E-1NoMyjq7AQpx1cBdow<mpl=sheets&osid=1&passive=1209600&service=wise&flowName=GlifWebSignIn&flowEntry=ServiceLogin&dsh=S-7251167306%3A3477788878142089&theme=glif#gid=0',
|
|
565
|
+
'https://bezpiecznedane.gov.pl/auth/realms/DGWEYGSWOGTAOG/login-actions/first-broker-login?client_id=knxzfnmxtndvtn-pn&tab_id=dHvCjad6CwW',
|
|
566
|
+
'https://account.proton.me/authorize?app=proton-mail&state=ipbfP1pSOwS2N236jXMnEQ-zkpWoK06cUtvikQ7qyXq&u=0',
|
|
567
|
+
].forEach((url) => {
|
|
568
|
+
it(`should drop URL: ${url}`, function () {
|
|
569
|
+
shouldBeTruncated(url);
|
|
570
|
+
});
|
|
571
|
+
});
|
|
572
|
+
});
|
|
573
|
+
|
|
574
|
+
describe('should truncate login specific URLs', function () {
|
|
575
|
+
[
|
|
576
|
+
'https://access.ing.de/delogin/w/login?t=https://access.ing.de/delogin/oauth/authorize?response_type%3Dcode%26client_id%3Dibbr%26scope%3Dbanking%2520postlogin%2520tpa%2520openid%26state%3DAXHw4viZF1ntx4i3gOcflIUKUK80Yix3Hr5LNsb0j0I%253D%26redirect_uri%3Dhttps://banking.ing.de/app/login/oauth2/code/ibbr%26nonce%3D9WjJS-aqnwAoAFd8fF4t5nNLuO-DsPA0ql-oKMGZ6zo%26claims%3D%257B%2522id_token%2522%253A%257B%2522customer_number%2522%253A%257B%2522essential%2522%253Atrue%257D%252C%2522partner_number%2522%253A%257B%2522essential%2522%253Atrue%257D%252C%2522last_login%2522%253A%257B%2522essential%2522%253Atrue%257D%252C%2522authentication_means%2522%253A%257B%2522essential%2522%253Atrue%257D%257D%257D',
|
|
577
|
+
'https://web.verimi.de/dipp/api/authenticate?login_challenge=498830e1f9734aebab6f382f673a20e5',
|
|
578
|
+
'https://accounts.google.com/signin/v2/usernamerecovery?continue=https%3A%2F%2Fgroups.google.com%2Fmy-groups&dsh=S285380746%3A1697710203082833&flowEntry=ServiceLogin&flowName=GlifWebSignIn&followup=https%3A%2F%2Fgroups.google.com%2Fmy-groups&ifkv=AVQVeyyeWVx_JoNaqej1zdzdZjDsJ1zQCgD0KdudwHwmez4dVJkWw_4bZVCCj46vLQVUVJGrBIxj&osid=1&theme=glif',
|
|
579
|
+
'https://accounts.google.com/v3/signin/identifier?continue=https%3A%2F%2Fwww.youtube.com%2Fsignin%3Faction_handle_signin%3Dtrue%26app%3Ddesktop%26hl%3Den%26next%3Dhttps%253A%252F%252Fwww.youtube.com%252F&ec=65620&hl=en&ifkv=AVQVeyyBkkwVyKEUa4Ul-Mll2WwmLVdi14ivGA8Cyxy2zYPVY1nAWoGydpfvNuPwgbFGJB9QrlpO&passive=true&service=youtube&uilel=3&flowName=GlifWebSignIn&flowEntry=ServiceLogin&dsh=S1006818886%3A1697723402009676&theme=glif',
|
|
580
|
+
'https://accounts.google.com/v3/signin/identifier?continue=https%3A%2F%2Fgroups.google.com%2Fmy-groups&followup=https%3A%2F%2Fgroups.google.com%2Fmy-groups&ifkv=AVQVeyyBm7cgqI8WYA9rOCycOcMyWoz7q8f1d0PTs9qu6Xj7evUrAr2u1DvlW9XklbfNlH4B324E&osid=1&passive=1209600&flowName=GlifWebSignIn&flowEntry=ServiceLogin&dsh=S285380746%3A1697710203082833&theme=glif',
|
|
581
|
+
'https://access.ing.de/delogin/w/login?x=sym2BPHMFmqV2hYUXnMw-YbrjfmV2Rsq2JfGZpNH1SnjUKBT1RYcA4A&t=https://access.ing.de/delogin/oauth/authorize%3Fresponse_type%3Dcode%26client_id%3Dibbr%26scope%3Dbanking%2520postlogin%2520tpa%2520openid%26state%3DAXHw4viZF1ntx4i3gOcflIUKUK80Yix3Hr5LNsb0j0I%253D%26redirect_uri%3Dhttps://banking.ing.de/app/login/oauth2/code/ibbr%26nonce%3D9WjJS-aqnwAoAFd8fF4t5nNLuO-DsPA0ql-oKMGZ6zo%26claims%3D%257B%2522id_token%2522%253A%257B%2522customer_number%2522%253A%257B%2522essential%2522%253Atrue%257D%252C%2522partner_number%2522%253A%257B%2522essential%2522%253Atrue%257D%252C%2522last_login%2522%253A%257B%2522essential%2522%253Atrue%257D%252C%2522authentication_means%2522%253A%257B%2522essential%2522%253Atrue%257D%257D%257D',
|
|
582
|
+
'https://www.facebook.com/recover/initiate/?privacy_mutation_token=eyJ0eXBlIjowLCJjcmVhdGlvbl90aW1lIjoxNjk3NzEyMTMyLCJjYWxsc2l0ZV9pZCI6MzgxMjI5MDc5NTc1OTQ2fQ==&ars=facebook_login',
|
|
583
|
+
'https://www.facebook.com/login/identify/?ctx=recover&ars=facebook_login&from_login_screen=0#',
|
|
584
|
+
'https://signon.ghostery.com/en/password/forgot?redirect=https%3A%2F%2Faccount.ghostery.com%2Fen%2F',
|
|
585
|
+
'https://signin.aws.amazon.com/signin?redirect_uri=https%3A%2F%2Fconsole.aws.amazon.com%2Fconsole%2Fhome%3FhashArgs%3D%2523%26isauthcode%3Dtrue%26nc2%3Dh_ct%26src%3Dheader-signin%26state%3DhashArgsFromTB_eu-north-1_7bbe8829a3606007&client_id=arn%3Aaws%3Asignin%3A%3A%3Aconsole%2Fcanvas&forceMobileApp=0&code_challenge=LfgbfGbtRHU3oaW7r8IvAWwD2OYiD-yJqcfaXtAijew&code_challenge_method=SHA-256',
|
|
586
|
+
'https://panel.bunny.net/user/login/verifycode?ReturnUrl=',
|
|
587
|
+
'https://panel.bunny.net/user/logout',
|
|
588
|
+
'https://www.faz.net/mein-faz-net/?redirectUrl=%2Faktuell%2F',
|
|
589
|
+
'https://www.linkedin.com/authwall?trk=gf&trkInfo=ZBP-qZA0VYwULcZZZXcGa-IBpJOvTmi8dPOR8ko77BJLmkKxvMbI4TEk4rr0gbxqkLN1kKQaWGMb10uEdpF_o5_WyIHxZVft5xLgXHsd68beuKzKDoALJ-Vh8OfiHZ8rrNnEiB7=&original_referer=&sessionRedirect=https%3A%2F%2Fuk.linkedin.com%2Fin%2Fzhaohan-daniel-guo-22475b15',
|
|
590
|
+
'https://www.dolce-gusto.be/m/customer/account/login/referer/oVW4hVY5Lr70i0heHD7bK8NxH0OmiD9eKaNsfJ7xkSAsfcOm/?___store=ndg_be_nl_mobile&___from_store=ndg_be_fr_mobile',
|
|
591
|
+
'https://www.dolce-gusto.ch/m/customer/account/login/referer/fKT4oKX9Iv18n8ouZC1mQ2WcZ8AdnC7uQ2krbJ1mnB6wbv4vXd1qUMYqHxNcoGcdfC18URHlnxlln01dnB0cQRH6R2Hmb2Dp/?___store=ndg_ch_fr_mobile&___from_store=ndg_ch_de_mobile',
|
|
592
|
+
'https://billtobox.zendesk.com/auth/v2/login/signin?auth_origin=114094533013,false,true&brand_id=114094533013&return_to=https://billtobox.zendesk.com/&theme=hc',
|
|
593
|
+
'https://authentication.cardexchangecloud.com/Account/ForgetPassword?returnUrl=/connect/authorize/callback?client_id=spa&redirect_uri=https://controller.cardexchangecloud.com/auth/controller/login&response_type=id_token token&scope=openid profile email roles customer api1 restricted_resources&nonce=N0.787868080387803273027583911101&state=90251394777337.1094681119101925',
|
|
594
|
+
'https://authentication.cardexchangecloud.com/Account/ForgetPassword?returnUrl=/connect/authorize/callback?client_id=spa&redirect_uri=https://controller.cardexchangecloud.com/auth/controller/login&response_type=id_token%20token&scope=openid%20profile%20email%20roles%20customer%20api1%20restricted_resources&nonce=N0.787868080387803273027583911101&state=90251394777337.1094681119101925',
|
|
595
|
+
'https://weibo.com/login.php?url=https%3A%2F%2Fus.weibo.com%2Findex',
|
|
596
|
+
'https://weibo.com/newlogin?tabtype=weibo&gid=102803&openLoginLayer=0&url=https%3A%2F%2Fweibo.com%2F',
|
|
597
|
+
'https://login.sina.com.cn/sso/prelogin.php?entry=weibo&callback=sinaSSOController.preloginCallBack&su=&rsakt=mod&client=ssologin.js(v1.4.19)&_=1702040031979',
|
|
598
|
+
'https://audit.verified-data.com/email/verify/4769/6v2h6102n8f226979f0p981n327v3p061vf4ff2v?expires=1702297704&signature=67m0m205375800m7605j0m6j13wrr328r0q24j3wy127wjj52y417r82414189jy',
|
|
599
|
+
'https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fghostery',
|
|
600
|
+
'https://us-east-1.signin.aws/platform/resetpassword?workflowStateHandle=51u55f00-u9u2-27d3-1575-dd80947u0541',
|
|
601
|
+
].forEach((url) => {
|
|
602
|
+
it(`should truncate URL: ${url}`, function () {
|
|
603
|
+
shouldBeTruncated(url);
|
|
604
|
+
});
|
|
605
|
+
});
|
|
606
|
+
});
|
|
607
|
+
|
|
608
|
+
describe('should truncate URLs containing account information', function () {
|
|
609
|
+
[
|
|
610
|
+
'https://foobar.awsapps.com/start/#/saml/custom/813451362916%20%28Foobarry%29/XA25oDRyH4Y6MWP4L2karl4lX1LmJwF5NTXzXKm7N3yJZ9ByAnL1N4IaGmDrN1J0GDn51R',
|
|
611
|
+
'https://www.otto.de/order/checkout/order/confirmation/1bqz64511y17d1b72zs8yys9120sbs6d71syz643q188syq3dsdq8393483d3176',
|
|
612
|
+
].forEach((url) => {
|
|
613
|
+
it(`should truncate URL: ${url}`, function () {
|
|
614
|
+
shouldBeTruncated(url);
|
|
615
|
+
});
|
|
616
|
+
});
|
|
617
|
+
});
|
|
618
|
+
|
|
619
|
+
describe('should truncate URLs with redirect links', function () {
|
|
620
|
+
[
|
|
621
|
+
'https://consent.youtube.com/m?continue=https%3A%2F%2Fm.youtube.com%2Fchannel%2FYZZlacy1v-3NY4gUUiQXLiZu%3Fcbrd%3D1&gl=DE&m=1&pc=yt&cm=2&hl=en&src=1',
|
|
622
|
+
].forEach((url) => {
|
|
623
|
+
it(`should drop URL: ${url}`, function () {
|
|
624
|
+
shouldBeTruncated(url);
|
|
625
|
+
});
|
|
626
|
+
});
|
|
627
|
+
});
|
|
628
|
+
|
|
629
|
+
// TODO: how to deal with shorteners?
|
|
630
|
+
// describe('should truncate URL shortener links in strict mode', function () {
|
|
631
|
+
// [
|
|
632
|
+
// 't.ly/PKKKy',
|
|
633
|
+
// 'is.gd/PazNcR',
|
|
634
|
+
// 'bit.ly/1h0ceQI',
|
|
635
|
+
// 'goo.gl/bdkh1L',
|
|
636
|
+
// 't.co/RUiFUYKzkz',
|
|
637
|
+
// 'buff.ly/2LrnrP8',
|
|
638
|
+
// ].forEach((url) => {
|
|
639
|
+
// it(`should truncate URL: ${url}`, function () {
|
|
640
|
+
// shouldBeTruncatedInStrictMode(`http://${url}`);
|
|
641
|
+
// shouldBeTruncatedInStrictMode(`https://${url}`);
|
|
642
|
+
// });
|
|
643
|
+
// });
|
|
644
|
+
// });
|
|
645
|
+
|
|
646
|
+
describe('should truncate URLs with long IDs', function () {
|
|
647
|
+
[
|
|
648
|
+
'https://www.bing.com/ck/a?!&&p=badf679299367c84JmltdHM9MTY5NzY3MzYwMCZpZ3VpZD0xNDY2M2EzMS1kMjdlLTY1YTQtMzhlYy0yOTY4ZDM5NTY0ZTkmaW5zaWQ9NTIxMg&ptn=3&hsh=3&fclid=14663a31-d27e-65a4-38ec-2968d39564e9&u=a1aHR0cHM6Ly9ibG9nLnRlbnNvcmZsb3cub3JnLzIwMjEvMDEvY3VzdG9tLW9iamVjdC1kZXRlY3Rpb24taW4tYnJvd3Nlci5odG1s&ntb=1',
|
|
649
|
+
'https://travel.cytric.net/env-a/ibe/?id=512837228%7E0%7Er&prg=112853-2272319397102-3&_dp_=ANHVXLQx_JaKkRxyLHTNkSO3NLHXu92NjHNiHX4bN2H',
|
|
650
|
+
'https://www.youtube.com/redirect?event=video_description&redir_token=QUXFLUhra7ZsRUQ3NKxZX2tUNmxzTjdjS2zZUGk7SZMYd3xBZ4Jnl3tud3JxSTRCXFI2R1o4M2yXRXd0fVQ8ZFY0dxJxRCFFZHprVWtjem53RPR0OUlYQxZEXzNiNmhELTcwbXVibEdMgmNbcml5YblXZAsiYgFoKG15NutRcC74LAtNczW2X22JZFABc2GZWFRvWjgsbXkxR2&q=https%3A%2F%2Farxiv.org%2Fabs%2F2310.08560&v=AITOuXUi9pg',
|
|
651
|
+
'https://pvn.mediamarkt.de/trck/eclick/40907yqy0glbl95qll57qbb59by842yl?subid=7248708625399259997&mfadid=adm',
|
|
652
|
+
'https://timeline.google.com/maps/timeline?authuser=0&hl=de&pli=1&rapt=SOfYD4WykrYUYAj2H0pCAn7cYzQ24k4GQIbQ5UVKER0YlVY54F420EMqcT7yl084f_b0O0-NdKY3lnWR0csEGZOAqkVzc7UXR0KKwZsooOFB4vu5xW7p8QU&pb',
|
|
653
|
+
'https://img.search.brave.com/U4gou0jGxeFs9qethbxRGqeOMRcOH4enMRstvUnSSqq/rs:fit:640:904:1/g:ce/jZY2xZI4Vm0dVvFd/julwGz9ej75mAaZ7/qI1lAz1gAB39UB1l/A7F8UJllUOM8ZJRl/PeCeAOCyZJs8PJVu/UOstGeCsPB5wjTD5/YWxoZWFkLWFsaXNz/VF18dRu5XF1obTA0/LmpwZw',
|
|
654
|
+
'https://consent.yahoo.com/v2/collectConsent?sessionId=3_cc-session_14392mo1-s856-4sk6-2986-28o5k4o1p429',
|
|
655
|
+
'https://www.bloomberg.com/tosv2.html?vid=34g704g1-99yy-66jj-q27m-3m1qqsq454qq&uuid=784qc164-33qq-77ff-5n7q-fn47462b6933&url=L25ld3MvdGVybWluYWwvUloyNE1FTUIyU0pR',
|
|
656
|
+
'https://www.dolce-gusto.es/m/customer/account/login/referer/iDL9uDF7Ve52k2ujJI5xC1UzJ2KtkI8jJWFasT5wC1Egu15eiG5tV1bwuvkgVWkwkIKekIMjie3qiGEls1ba',
|
|
657
|
+
'https://bezpiecznedane.gov.pl/sprawdz-email?state=fKtjCqpHfo00Eut6UvELEqigtwA3lPGMG9uzOZ7pCSEoFYNpaz9ixqtJER9g&session_state=bd3865bg-g5i1-85g6-254z-9b2jd4z02z12&code=4398735i-7741-40t9-i1l9-30761t6t0bt0.xt64i8xj-jyl3-42j7-9l1i-5x9bi1i09i39.773i9865-7x4l-4x5i-7625-9207j4l31884',
|
|
658
|
+
'https://bildungsportal.sachsen.de/opal/auth/RepositoryEntry/762071641/CourseNode/58610245676829/wiki/Index;jsessionid=N048JED1779324348E7E8C39EE9C7445.opalN5?0',
|
|
659
|
+
'https://docs.google.com/spreadsheets/d/3TJlhj3Zi09g-gwshAljvTdZUz2iXauEo5q9vprZM-GA/edit#gid=0',
|
|
660
|
+
'https://docs.google.com/spreadsheets/d/3TJlhj3Zi09g-gwshAljvTdZUz2iXauEo5q9vprZM-GA/edit',
|
|
661
|
+
'https://www.aliexpress.com/gcp/300001278/Mainvenue?disableNav=YES&pha_manifest=ssr&_immersiveMode=true&aff_fcid=34774b22fc3b4bdb9b1027ab41d31022-1703165608590-05507-_DlRCXbX&tt=CPS_NORMAL&aff_fsk=_DlRCXbX&aff_platform=portals-promotion&sk=_DlRCXbX&aff_trace_key=34774b22fc3b4bdb9b1027ab41d31022-1703165608590-05507-_DlRCXbX&terminal_id=33248a347d6f4043bd1041b4151973e6',
|
|
662
|
+
'http://agenciahabitatge.gencat.cat/wps/portal/!ut/p/z1/sXWWm8JoYJm_Quo3UlVWGcJlineL1FlGLbZB5QZcLWGClhQW_fy91tqOcQAB1JbcSO0bvFYOHFltt9eiWUeM46oSZl3BY20xUlL2QJ8YLe1x2-29LdOIlEjSI8HveoaOLD2f2IAVEHqupBGTvovFHduHz0VKEzLHMCoIbz7z1lqigHsaf-89USmo3COcow2LrGXxkUvP1QtlHwQLrnohqViRyOW8KD2XIcwuPsWWuwZnwIUo5op3kzG_IPP-BVucpSSYyrIix4F9EXV5XShRk6JkUvoIZ0fr45iKTivqcpuYh_q9H5FLyZM5ZKgEXbBquz9aupp97dksk78uJrUF2A9OIhM5trZ9u27V2SiElsAudfEnGvQI6tDoVBxMDDQj5_rzLUpgVG3BVmSoXwEtHk_XhbRrWB-h_CcNprkqkdkKYybGy4RuM0_VFgsALY7dF290trAri9JadCEe80c6z95_Lpw-Qyk!/qh/q5/K1qLJHExX7VLJH6gZHEu/?urile=wcm:path:/ahcca/web/serveis/programes socials/xarxa mediacio lloguer social',
|
|
663
|
+
'http://agenciahabitatge.gencat.cat/wps/portal/!ut/p/z1/sXWWm8JoYJm_Quo3UlVWGcJlineL1FlGLbZB5QZcLWGClhQW_fy91tqOcQAB1JbcSO0bvFYOHFltt9eiWUeM46oSZl3BY20xUlL2QJ8YLe1x2-29LdOIlEjSI8HveoaOLD2f2IAVEHqupBGTvovFHduHz0VKEzLHMCoIbz7z1lqigHsaf-89USmo3COcow2LrGXxkUvP1QtlHwQLrnohqViRyOW8KD2XIcwuPsWWuwZnwIUo5op3kzG_IPP-BVucpSSYyrIix4F9EXV5XShRk6JkUvoIZ0fr45iKTivqcpuYh_q9H5FLyZM5ZKgEXbBquz9aupp97dksk78uJrUF2A9OIhM5trZ9u27V2SiElsAudfEnGvQI6tDoVBxMDDQj5_rzLUpgVG3BVmSoXwEtHk_XhbRrWB-h_CcNprkqkdkKYybGy4RuM0_VFgsALY7dF290trAri9JadCEe80c6z95_Lpw-Qyk!/qh/q5/K1qLJHExX7VLJH6gZHEu/?urile=wcm:path:/ahcca/web/serveis/programes+socials/xarxa+mediacio+lloguer+social',
|
|
664
|
+
].forEach((url) => {
|
|
665
|
+
it(`should drop URL: ${url}`, function () {
|
|
666
|
+
shouldBeTruncated(url);
|
|
667
|
+
});
|
|
668
|
+
});
|
|
669
|
+
|
|
670
|
+
[
|
|
671
|
+
'https://r.mail.ghostery.com/tr/op/gmGv_I5hqw15bLLyxG0g_FhuZlFYDvGtTVorqzYSqVLR3RLxY4m0GJdAImute2xfJAes2ji4QY4WKRYcsxAKf2dhr5Cdy4RLIyjFhBnoqV5iRyfKuCFYA_czVe-otbPjOWKmpLbZLbAlsVY84mTElAaDexyEuR5ckuyewGMFQpYdvpzl7xQfF-73YkWJHIPGz3B8a_uLLs_mqcIc6NfdkwHRecKOwWoarMIZ',
|
|
672
|
+
'https://beethoven-viur.appspot.com/file/download/AMIfv94I1TCuh-LQwE0klfULZBhalx4up4WpLqX_Etc-TcWqZUjb6NfQw1_t6g_YkGzFMNV34YJh7C0xg5JJIPeWloEE91HDLpPAKQxiVbh6DpGyjYnXcnt9BpMPrMCCuAOeNbZnTL5XEGFbQPP3c5HmotrmnePPcyMD1ieFE0ABr2Tbfxb5LSIgcEh6U8N8l-V-7-UZqEsfqngbNdfpPm2tbndF5mdZaokbBjHirguv0Tj--Yzms_WfrVmvllxKgyG97QFptkf3OWTZzwFkmw80xn52EvRMRzfpc7YjewUX8ctZ4bLW5Cc/Beethoven_Diskographie_10.pdf',
|
|
673
|
+
].forEach((url) => {
|
|
674
|
+
it(`should drop URL (in strict mode): ${url}`, function () {
|
|
675
|
+
shouldBeTruncatedInStrictMode(url);
|
|
676
|
+
});
|
|
677
|
+
});
|
|
678
|
+
});
|
|
679
|
+
|
|
680
|
+
describe('should truncate URLs with base64 content', function () {
|
|
681
|
+
[
|
|
682
|
+
'https://www.e-recht24.de/websitescanner?hash=LIcnBHJ80eL1vZzFQJYUCgkwR3uB0yFtKwIrTb8uQC4Ibu7Yn1CeebupSJhPbIYV&u=aHR0cHM6Ly93d3cuZ2hvc3RlcnkuY29tLw==',
|
|
683
|
+
].forEach((url) => {
|
|
684
|
+
it(`should drop URL: ${url}`, function () {
|
|
685
|
+
shouldBeTruncated(url);
|
|
686
|
+
});
|
|
687
|
+
});
|
|
688
|
+
});
|
|
689
|
+
|
|
690
|
+
describe('should support news sites', function () {
|
|
691
|
+
describe('that use UUIDs in their article URLs', function () {
|
|
692
|
+
[
|
|
693
|
+
'https://www.ft.com/content/b08c3159-982e-4831-8897-e35f8aca49e1',
|
|
694
|
+
'https://www.ft.com/content/820e66cc-fc8a-4ca9-811d-66cf2c6f0439',
|
|
695
|
+
'https://www.ft.com/content/95d47316-b357-4fc3-b25d-34645eef8abc',
|
|
696
|
+
'https://www.ft.com/content/2699f3c0-78b4-4f73-880e-629375282f73',
|
|
697
|
+
'https://www.propublica.org/article/warren-buffett-privately-traded-stocks-berkshire-hathaway-ethics-irs',
|
|
698
|
+
'https://www.spiegel.de/international/world/forgotten-in-kyiv-support-slides-for-ukraine-following-attack-on-israel-a-68f0b813-d558-4506-9354-5b632d9cf97a',
|
|
699
|
+
'https://www.spiegel.de/ausland/mrbeasts-100-brunnen-ein-beruehmter-youtuber-will-afrika-retten-a-9bf428b2-6ca2-419e-9623-d5983eb710fd',
|
|
700
|
+
'https://www.rnd.de/medien/mrbeast-youtuber-stellt-einkommensrekord-auf-XQDPXC2VVVAN7JYQ7SCWJJQZBY.html',
|
|
701
|
+
].forEach((url) => {
|
|
702
|
+
it(`should allow URL: ${url}`, function () {
|
|
703
|
+
shouldBeSafeInNonStrictMode(url);
|
|
704
|
+
});
|
|
705
|
+
});
|
|
706
|
+
});
|
|
707
|
+
|
|
708
|
+
describe('that use hashes in their article URLs', function () {
|
|
709
|
+
[
|
|
710
|
+
'https://www.huffpost.com/entry/peter-thiel-trump-2024_n_654ddddee4b0373d70b196d1',
|
|
711
|
+
'https://www.lbc.co.uk/world-news/1fe04e54197741a9accba85a1abaf21c/',
|
|
712
|
+
'https://www.ouest-france.fr/monde/israel/ce-que-lon-sait-des-journalistes-accuses-davoir-couvert-lattaque-du-hamas-le-7-octobre-en-israel-e30b9f18-7fd5-11ee-a407-397218b61e71',
|
|
713
|
+
'https://www.elmundo.es/espana/2024/06/05/665f542fe9cf4a3c598b4584.html',
|
|
714
|
+
'https://www.sueddeutsche.de/wissen/palaeoanthropologie-menschenaffen-hammerschmiede-lux.Pwq48LbZ4WW92NgCaZWiJT',
|
|
715
|
+
].forEach((url) => {
|
|
716
|
+
it(`should allow URL: ${url}`, function () {
|
|
717
|
+
shouldBeSafe(url);
|
|
718
|
+
});
|
|
719
|
+
});
|
|
720
|
+
});
|
|
721
|
+
|
|
722
|
+
describe('that use numbers in their article URLs', function () {
|
|
723
|
+
[
|
|
724
|
+
'https://www.wsj.com/personal-finance/mortgage-home-buying-rent-down-payment-41308669',
|
|
725
|
+
'https://taz.de/CDU-beendet-Schwarz-Gruen-in-Hessen/!5969307/',
|
|
726
|
+
'https://taz.de/Taylor-Swift-in-Argentinien/!5969351/',
|
|
727
|
+
'https://www.focus.de/sport/fussball/2-bundesliga-schwere-ausschreitungen-in-hamburg-hannover-fans-pruegeln-sich-mit-der-polizei_id_243186606.html',
|
|
728
|
+
'https://www.wiwo.de/my/politik/ausland/usa-vs-china-das-duell-der-giganten/29490956.html',
|
|
729
|
+
'https://www.handelsblatt.com/politik/konjunktur/sinkende-verbraucherpreise-china-rutscht-wieder-in-die-deflation/29491072.html',
|
|
730
|
+
'https://www.unilad.com/film-and-tv/news/martin-scorsese-daughter-tiktok-never-film-372949-20231110',
|
|
731
|
+
'https://www.bristolpost.co.uk/news/bristol-news/support-bristols-island-neighbourhood-after-8898769',
|
|
732
|
+
'https://de.finance.yahoo.com/nachrichten/tailg-pr%C3%A4sentiert-neue-tlg-marke-202500300.html',
|
|
733
|
+
'https://de.nachrichten.yahoo.com/prosieben-magazin-zervakis-opdenh%C3%B6vel-live-204617336.html',
|
|
734
|
+
'https://www.tagesspiegel.de/politik/bundeswehrtagung-und-wehretat-bald-knallt-es-zwischen-pistorius-und-scholz-10762537.html',
|
|
735
|
+
'https://www.t-online.de/nachrichten/deutschland/innenpolitik/id_100278508/muss-die-bundeswehr-kriegstuechtig-sein-stimmen-aus-dem-bundestag.html',
|
|
736
|
+
'https://www.nzz.ch/feuilleton/israel-zeigt-bilder-des-grauens-auch-hamas-kennt-ihre-wirkmacht-ld.1764329',
|
|
737
|
+
'https://www.bild.de/bild-plus/regional/berlin/berlin-aktuell/pflegedienst-berlin-falsche-medikamente-misshandlung-zwei-tote-senioren-ermittlu-86042368.bild.html',
|
|
738
|
+
'https://www.dailymail.co.uk/news/article-12735811/Why-Charles-great-pain-Harry-King-host-small-party-close-friends-not-family-celebrate-75th-birthday-marks-occasion-striking-portrait.html',
|
|
739
|
+
'https://www.motorsport-total.com/auto/news/royal-enfield-himalayan-452-2024-feiert-premiere-auf-der-eicma-23111005',
|
|
740
|
+
'https://sportowefakty.wp.pl/koszykowka/fototemat/1090963/kosmiczne-pieniadze-zobacz-ile-zarabiaja-gwiazdy-nba-sochan-daleko',
|
|
741
|
+
'https://www.sueddeutsche.de/wissen/technik-radargeraete-koennen-router-funkband-lahmlegen-dpa.urn-newsml-dpa-com-20090101-170322-99-767363',
|
|
742
|
+
].forEach((url) => {
|
|
743
|
+
it(`should allow URL: ${url}`, function () {
|
|
744
|
+
shouldBeSafe(url);
|
|
745
|
+
});
|
|
746
|
+
});
|
|
747
|
+
});
|
|
748
|
+
|
|
749
|
+
describe('that use dates for their article URLs', function () {
|
|
750
|
+
[
|
|
751
|
+
'https://www.nytimes.com/2023/11/10/nyregion/adams-fbi-investigation-phones.html',
|
|
752
|
+
'https://www.npr.org/sections/health-shots/2023/11/09/1211610533/science-says-teens-need-more-sleep-so-why-is-it-so-hard-to-start-school-later',
|
|
753
|
+
'https://www.npr.org/2023/11/09/953342565/nasa-apollo-gemini-astronaut-frank-borman-dies',
|
|
754
|
+
'https://www.washingtonpost.com/food/2023/11/09/american-tipping-confusion-culture-study/',
|
|
755
|
+
'https://www.forbes.com/sites/willskipworth/2023/11/10/billionaire-investor-predicts-spacexs-starlink-will-go-public-around-2027/',
|
|
756
|
+
'https://www.bbc.com/worklife/article/20231108-three-big-reasons-americans-havent-rapidly-adopted-evs',
|
|
757
|
+
'https://edition.cnn.com/2023/11/10/asia/pakistan-india-pollution-new-delhi-lahore-intl-hnk/index.html',
|
|
758
|
+
'https://www.theguardian.com/us-news/2023/nov/10/trump-classified-documents-trial-date-aileen-cannon',
|
|
759
|
+
'https://www.bfmtv.com/pratique/shopping/black-friday-les-dates-officielles-de-l-edition-2023_AB-202310280026.html',
|
|
760
|
+
'https://www.lefigaro.fr/politique/emmanuel-macron-ne-se-rendra-pas-a-la-marche-contre-l-antisemitisme-dimanche-a-paris-20231110',
|
|
761
|
+
'https://www.lemonde.fr/politique/article/2023/11/10/emmanuel-macron-ne-se-rendra-pas-a-la-marche-contre-l-antisemitisme-mais-salue-des-rassemblements-qui-sont-un-motif-d-esperance_6199414_823448.html',
|
|
762
|
+
'https://www.washingtonpost.com/world/asia_pacific/climate-change-crowding-imperil-iconic-route-to-top-of-mount-everest/2018/05/16/4d975094-547a-11e8-a6d4-ca1d035642ce_story.html',
|
|
763
|
+
].forEach((url) => {
|
|
764
|
+
it(`should allow URL: ${url}`, function () {
|
|
765
|
+
shouldBeSafe(url);
|
|
766
|
+
});
|
|
767
|
+
});
|
|
768
|
+
});
|
|
769
|
+
|
|
770
|
+
describe('that use long text in their article URLs', function () {
|
|
771
|
+
[
|
|
772
|
+
'https://www.foxnews.com/entertainment/dwayne-rock-johnson-says-political-parties-approached-run-president-one-other',
|
|
773
|
+
'https://www.gbnews.com/royal/princess-eugenie-princess-beatrice-prince-william-working-royals-latest',
|
|
774
|
+
'https://www.propublica.org/article/warren-buffett-privately-traded-stocks-berkshire-hathaway-ethics-irs',
|
|
775
|
+
'https://www.lbc.co.uk/news/cenotah-armistice-ring-of-steel-sunak-bans-smaller-protests/',
|
|
776
|
+
'https://pressgazette.co.uk/media-audience-and-business-data/media_metrics/most-popular-websites-news-us-monthly-3/',
|
|
777
|
+
'https://www.radiotimes.com/tv/sci-fi/doctor-who-60th-anniversary-special-flux-connection-newsupdate/',
|
|
778
|
+
'https://screenrant.com/star-wars-bo-katan-the-mandalorian-season-4-return-tease/',
|
|
779
|
+
'https://www.swr.de/swraktuell/baden-wuerttemberg/suedbaden/trauer-in-offenburg-um-erschossenen-schueler-100.html',
|
|
780
|
+
'https://www.lto.de/recht/justiz/j/geisterstunde-arbeitsgericht-koeln-videoverhandlung-ton-bild-urteil-erfunden-mysterioes/',
|
|
781
|
+
].forEach((url) => {
|
|
782
|
+
it(`should allow URL: ${url}`, function () {
|
|
783
|
+
shouldBeSafe(url);
|
|
784
|
+
});
|
|
785
|
+
});
|
|
786
|
+
});
|
|
787
|
+
});
|
|
788
|
+
|
|
789
|
+
// TODO: reconsider these tests (yes, the pages should not be shared,
|
|
790
|
+
// but there are other factors that come into play:
|
|
791
|
+
// - Google Translate defines a safe canonical URL, which should be preferred
|
|
792
|
+
// - DeepL encodes its information as an anchor tag (which we arguably should drop)
|
|
793
|
+
describe('should truncate URLs that encode translations', function () {
|
|
794
|
+
[
|
|
795
|
+
'https://www.deepl.com/translator#en/de/This%20is%20a%20test',
|
|
796
|
+
'https://www.deepl.com/translator#de/en/Das%20ist%20ein%20Test',
|
|
797
|
+
"https://www.deepl.com/translator#fr/de/C'est%20un%20test",
|
|
798
|
+
'https://translate.google.com/?sl=en&tl=de&text=Lorem%20ipsum%20dolor%20sit%20amet%2C%20consetetur%20sadipscing%20elitr%2C%20sed%20diam%20nonumy%20eirmod%20tempor%20invidunt%20ut%20labore%20et%20dolore%20magna%20aliquyam%20erat%2C%20sed%20diam%20voluptua.%20At%20vero%20eos%20et%20accusam%20et%20justo%20duo%20dolores%20et%20ea%20rebum.%20Stet%20clita%20kasd%20gubergren%2C%20no%20sea%20takimata%20sanctus%20est%20Lorem%20ipsum%20dolor%20sit%20amet.%20Lorem%20ipsum%20dolor%20sit%20amet%2C%20consetetur%20sadipscing%20elitr%2C%20sed%20diam%20nonumy%20eirmod%20tempor%20invidunt%20ut%20labore%20et%20dolore%20magna%20aliquyam%20erat%2C%20sed%20diam%20voluptua.%20At%20vero%20eos%20et%20accusam%20et%20justo%20duo%20dolores%20et%20ea%20rebum.%20Stet%20clita%20kasd%20gubergren%2C%20no%20sea%20takimata%20sanctus%20est%20Lorem%20ipsum%20dolor%20sit%20amet.&op=translate',
|
|
799
|
+
'https://fanyi.baidu.com/#en/zh/This%20is%20a%20test',
|
|
800
|
+
].forEach((url) => {
|
|
801
|
+
it(`should drop URL: ${url}`, function () {
|
|
802
|
+
shouldBeTruncated(url);
|
|
803
|
+
});
|
|
804
|
+
});
|
|
805
|
+
});
|
|
806
|
+
|
|
807
|
+
describe('should truncate complex URLs but accept their simpler canononical URL counterparts', function () {
|
|
808
|
+
[
|
|
809
|
+
{
|
|
810
|
+
originalUrl:
|
|
811
|
+
'https://www.temu.com/uk/usb-global-travel-converter-multifunctional-plug-socket-u-s-british-standard-conversion-power-adapter-charger-g-601099519482147.html?_bg_fs=1&_p_rfs=1&_x_ads_channel=google&_x_ads_sub_channel=shopping&_x_login_type=Google&_x_vst_scene=adg&mkt_rec=1&goods_id=601099519482147&sku_id=17592228839019&_x_ns_sku_id=17592228839019&_x_gmc_account=435423729&locale_override=210~en~GBP&_x_ads_risk=1',
|
|
812
|
+
canonicalUrl:
|
|
813
|
+
'https://www.temu.com/uk/usb-global-travel-converter-multifunctional-plug-socket-u-s-british-standard-conversion-power-adapter-charger-g-601099519482147.html',
|
|
814
|
+
},
|
|
815
|
+
{
|
|
816
|
+
originalUrl:
|
|
817
|
+
'https://www.temu.com/uk/international-travel-universal-adapter-electrical-plug-for-uk-us-eu-au-to-eu-european-socket-converter-white-black-g-601099518817648.html?_bg_fs=1&_p_rfs=1&_x_ads_channel=google&_x_ads_sub_channel=shopping&_x_login_type=Google&_x_vst_scene=adg&mkt_rec=1&goods_id=601099518817648&sku_id=17592225932210&_x_ns_sku_id=17592225932210&_x_gmc_account=978927325&locale_override=210~en~GBP&_x_ads_risk=1',
|
|
818
|
+
canonicalUrl:
|
|
819
|
+
'https://www.temu.com/uk/international-travel-universal-adapter-electrical-plug-for-uk-us-eu-au-to-eu-european-socket-converter-white-black-g-601099518817648.html',
|
|
820
|
+
},
|
|
821
|
+
{
|
|
822
|
+
originalUrl:
|
|
823
|
+
'https://www.argos.co.uk/product/8586117?storeID=4483&istCompanyId=a74d8886-5df9-4baa-b776-166b3bf9111c&istFeedId=30f62ea9-9626-4cac-97c8-9ff3921f8558&istItemId=ixilqptpw&istBid=t',
|
|
824
|
+
canonicalUrl: 'https://www.argos.co.uk/product/8586117',
|
|
825
|
+
},
|
|
826
|
+
{
|
|
827
|
+
originalUrl:
|
|
828
|
+
'https://www.ebay.com.au/itm/133106580436?_trkparms=ispr%3D1&hash=item1efdc53bd4:g:ugAAAOSwgc5fGpCc&amdata=enc%3AAQAGAAACkPYe5NmHp%252B2JMhMi7yxGiTJkPrKr5t53CooMSQt2orsSHYXPhGXR5uguexJBeHwfgWEntFLFCxG9TnUVZwSLeR7C%252BXHym%252BGM0VtJnLB1L1eR4sX5KzW12iami5Zp40SkFEAuZbk8BKox9l34zLETKOY5zHrJmwt%252Bv9Oa3afvMrzG7kPBDRmPkCAmhJpB0bb%252F7gWc8mNyQWlz6R2Fha5nnLjR03AvMwyvh65v%252F86iijR3hKE8VU45h2kamfYKHaWQE6mpviuYvcgJHhvf%252FWUMCHQDgyXmy0p5U4TISywwdYkI3NnU89HQswzEz8gMcnR6iYskEQEokJChwYiEQnymzZc%252F4fx7vnheSDB%252BOSkmCIsd901xz%252BY2r8cG3eDqI90nHtl5vyCarwdiCJjFgsCoaLWYwvdgACkivSfO6gDV1PhbYqoh1Ke%252BnONygKkK9V%252BkasLxk3CSVAQSzJuYtypdQNAZ8wwyRG9qbfZkByOzyuvhqG1yrUEdj94c1YamtdctisISVOv%252FFC19XkhKfpvcMM5A%252F1OPGTnmyEGDjWo9DMi%252FoX7l7hyWHg0tCbmvNYdp%252ByS9Iw903LHf9dfCWYC7PsOLcSnrC2Sw6IZ1EM1ZW96So9HauMwJS55me0HVXyIOVvxbRrDqiSfbwBZk7SLP25F%252BCRmFSMTPybpZlC2%252FfsKb8I5ZFtd3MAvRJhDIRSGQx48v2Pep7Aey4f4N9Po1kgW61WyMs%252FJWkEkBdgVc%252Bd08T3Ceh2d6lkEbBNw2jiafYD9uN6ii%252BfC6nxj7qa1jMLJ9aBMnM6tWEsjczdeCmWsPhRh9ant9GUcDcfaXX2ygBvSgiT1SgDnHjCzm9tzhrrxrvO8o1RzvZE6xSr8n5OCg%7Campid%3APL_CLK%7Cclp%3A2334524',
|
|
829
|
+
canonicalUrl: 'https://www.ebay.com.au/itm/133106580436',
|
|
830
|
+
},
|
|
831
|
+
{
|
|
832
|
+
originalUrl:
|
|
833
|
+
'https://www.amazon.de/-/en/Lubluelu-Saugroboter-Wischfunktion-Lasernavigation-Roboterstaubsauger/dp/B0BQBQJ784/?_encoding=UTF8&ref_=dlx_gate_dd_dcl_tlt_20e77cb4_dt_pd_gw_unk&pd_rd_w=u0Mp3&content-id=amzn1.sym.c3d3e926-d22d-4baf-8520-b539a55dc072&pf_rd_p=c3d3e926-d22d-4baf-8520-b539a55dc072&pf_rd_r=XQVAFVHSAQ7Y8C84KBJ7&pd_rd_wg=mzrvx&pd_rd_r=63a47cb2-0408-49d9-8a2d-c04c23ae0c8b&th=1',
|
|
834
|
+
canonicalUrl:
|
|
835
|
+
'https://www.amazon.de/-/en/Lubluelu-Cleaner-Function-Navigation-Control/dp/B0BQBQJ784',
|
|
836
|
+
},
|
|
837
|
+
].forEach(({ originalUrl, canonicalUrl }) => {
|
|
838
|
+
it(`- originalUrl: ${originalUrl} with canonicalUrl: ${canonicalUrl}`, function () {
|
|
839
|
+
shouldBeTruncated(originalUrl);
|
|
840
|
+
shouldBeSafeInNonStrictMode(canonicalUrl);
|
|
841
|
+
});
|
|
842
|
+
});
|
|
843
|
+
});
|
|
844
|
+
|
|
845
|
+
describe('should support tracking-free landing pages of ads', function () {
|
|
846
|
+
[
|
|
847
|
+
'https://www.krankenversicherung-vergleiche.info/versicherungen/private-krankenversicherung/vergleich/k/',
|
|
848
|
+
'https://www.hansemerkur.de/angebote/private-krankenversicherung-selbststaendige',
|
|
849
|
+
'https://www.ottonova.de/ml/pkv-sparen-finanzen-top-leistungen',
|
|
850
|
+
'https://www.check24.de/private-krankenversicherung/',
|
|
851
|
+
].forEach((url) => {
|
|
852
|
+
it(`should allow URL: ${url}`, function () {
|
|
853
|
+
shouldBeSafe(url);
|
|
854
|
+
});
|
|
855
|
+
});
|
|
856
|
+
});
|
|
857
|
+
|
|
858
|
+
describe('when using the "tryPreservePath" option on a path that is safe', function () {
|
|
859
|
+
[
|
|
860
|
+
{
|
|
861
|
+
url: 'https://www.bauhaus.info/bodenfliesen/c/10000500?q=%3AAnwendungsbereich00000035%3AInnen',
|
|
862
|
+
whenEnabled:
|
|
863
|
+
'https://www.bauhaus.info/bodenfliesen/c/10000500 (PROTECTED)',
|
|
864
|
+
whenDisabled: 'https://www.bauhaus.info/ (PROTECTED)',
|
|
865
|
+
},
|
|
866
|
+
{
|
|
867
|
+
url: 'https://www.bauhaus.info/bodenfliesen/c/10000500?q=%3AAnwendungsbereich00000035%3AInnen#some-hash-that-should-be-removed',
|
|
868
|
+
whenEnabled:
|
|
869
|
+
'https://www.bauhaus.info/bodenfliesen/c/10000500 (PROTECTED)',
|
|
870
|
+
whenDisabled: 'https://www.bauhaus.info/ (PROTECTED)',
|
|
871
|
+
},
|
|
872
|
+
].forEach(({ url, whenEnabled, whenDisabled }) => {
|
|
873
|
+
describe(`for ${url}`, function () {
|
|
874
|
+
[true, false, undefined].forEach((strictFlag) => {
|
|
875
|
+
describe(`and strict=<${strictFlag}>`, function () {
|
|
876
|
+
it(`truncates to path ("${whenEnabled}") when "tryPreservePath" is enabled explicitly`, function () {
|
|
877
|
+
const option = { tryPreservePath: true };
|
|
878
|
+
if (strictFlag !== undefined) {
|
|
879
|
+
option.strict = strictFlag;
|
|
880
|
+
}
|
|
881
|
+
expect(sanitizeUrl(url, option).safeUrl).to.eql(whenEnabled);
|
|
882
|
+
});
|
|
883
|
+
|
|
884
|
+
it(`truncates to domain ("${whenDisabled}") when "tryPreservePath" is disabled explicitly`, function () {
|
|
885
|
+
const option = { tryPreservePath: false };
|
|
886
|
+
if (strictFlag !== undefined) {
|
|
887
|
+
option.strict = strictFlag;
|
|
888
|
+
}
|
|
889
|
+
expect(sanitizeUrl(url, option).safeUrl).to.eql(whenDisabled);
|
|
890
|
+
});
|
|
891
|
+
|
|
892
|
+
it(`truncates to domain ("${whenDisabled}") when "tryPreservePath" is disabled implicitly (by default)`, function () {
|
|
893
|
+
const option = {};
|
|
894
|
+
if (strictFlag !== undefined) {
|
|
895
|
+
option.strict = strictFlag;
|
|
896
|
+
}
|
|
897
|
+
expect(sanitizeUrl(url, option).safeUrl).to.eql(whenDisabled);
|
|
898
|
+
});
|
|
899
|
+
});
|
|
900
|
+
});
|
|
901
|
+
});
|
|
902
|
+
});
|
|
903
|
+
});
|
|
904
|
+
|
|
905
|
+
describe('when using the "tryPreservePath" option on a path that is NOT safe', function () {
|
|
906
|
+
[
|
|
907
|
+
{
|
|
908
|
+
url: 'https://example.test/this.should.trigger.a.violation@email.test/1234567890-1234567890-1234567890',
|
|
909
|
+
truncated: 'https://example.test/ (PROTECTED)',
|
|
910
|
+
},
|
|
911
|
+
].forEach(({ url, truncated }) => {
|
|
912
|
+
describe(`for ${url}`, function () {
|
|
913
|
+
[true, false, undefined].forEach((strictFlag) => {
|
|
914
|
+
it(`and strict=<${strictFlag}>`, function () {
|
|
915
|
+
const option = { tryPreservePath: true };
|
|
916
|
+
if (strictFlag !== undefined) {
|
|
917
|
+
option.strict = strictFlag;
|
|
918
|
+
}
|
|
919
|
+
const { result, safeUrl, reason } = sanitizeUrl(url, option);
|
|
920
|
+
expect(result).to.eql('truncated');
|
|
921
|
+
expect(safeUrl).to.eql(truncated);
|
|
922
|
+
expect(reason).to.be.a('string').that.is.not.empty;
|
|
923
|
+
});
|
|
924
|
+
});
|
|
925
|
+
});
|
|
926
|
+
});
|
|
927
|
+
});
|
|
928
|
+
|
|
929
|
+
describe('for URLs that do not fit in other categories', function () {
|
|
930
|
+
describe('but should be safe', function () {
|
|
931
|
+
[
|
|
932
|
+
'https://search.brave.com/search?q=ship+tensorflow+model+in+webextension',
|
|
933
|
+
'https://www.bing.com/search?q=youtube+anti-adblock+linux+os',
|
|
934
|
+
'https://x.com/foobar/status/1713305785659211991',
|
|
935
|
+
'https://help.adblockplus.org/hc/en-us/articles/4402789017747-A-site-asks-me-to-disable-ABP-What-to-do-',
|
|
936
|
+
'https://help.adblockplus.org/hc/en-us/articles/1500002533742-Adblock-Plus-breaks-the-websites-I-visit',
|
|
937
|
+
'https://mastodon.social/@campuscodi/111218275545652125?utm_source=substack&utm_medium=email',
|
|
938
|
+
'https://mastodon.social/@campuscodi/111218275545652125',
|
|
939
|
+
'https://netzpolitik.org/2021/privatsphaere-jugendschuetzerinnen-wollen-ausweiskontrolle-vor-pornoseiten/',
|
|
940
|
+
'https://twitter.com/gorhill/status/1713305785659211991',
|
|
941
|
+
'https://biblehub.com/sermons/auth/aitken/king_of_kings_and_lord_of_lords.htm',
|
|
942
|
+
'https://biblehub.com/sermons/auth/benson/an_acquaintance_with_christ_the_foundation_of_experimental_and_practical_religion.htm',
|
|
943
|
+
'https://akveo.github.io/nebular/docs/auth/getting-user-token',
|
|
944
|
+
'https://docs.aws.amazon.com/AmazonElastiCache/latest/red-ug/GettingStarted.html',
|
|
945
|
+
].forEach((url) => {
|
|
946
|
+
it(`should allow URL: ${url}`, function () {
|
|
947
|
+
shouldBeSafe(url);
|
|
948
|
+
});
|
|
949
|
+
});
|
|
950
|
+
|
|
951
|
+
[
|
|
952
|
+
'https://www.amazon.co.uk/Unidapt-Adapter-European-Adaptor-Visitor/dp/B08MWRNYXL',
|
|
953
|
+
'https://www.amazon.co.uk/Universal-Adapter-Worldwide-International-European-Black/dp/B0BVZ8VHHH',
|
|
954
|
+
'https://www.amazon.co.uk/Converter-Universal-Standard-Grounded-Portable/dp/B09PBH4JT1',
|
|
955
|
+
'https://www.homedepot.com/p/Makita-Dust-Extracting-Nozzle-for-use-with-Makita-1-1-4-HP-Compact-Router-and-Plunge-Base-model-RT0701C-194733-8/205182383',
|
|
956
|
+
'https://www.youtube.com/watch?app=desktop&v=hLT-W55y-LI',
|
|
957
|
+
'https://www.youtube.com/watch?v=hLT-W55y-LI',
|
|
958
|
+
].forEach((url) => {
|
|
959
|
+
it(`should allow URL (in non-strict mode): ${url}`, function () {
|
|
960
|
+
shouldBeSafeInNonStrictMode(url);
|
|
961
|
+
});
|
|
962
|
+
});
|
|
963
|
+
});
|
|
964
|
+
|
|
965
|
+
describe('but should be rejected', function () {
|
|
966
|
+
[
|
|
967
|
+
// (currently empty)
|
|
968
|
+
].forEach((url) => {
|
|
969
|
+
it(`should reject URL: ${url}`, function () {
|
|
970
|
+
shouldBeDroppedOrTruncated(url);
|
|
971
|
+
});
|
|
972
|
+
});
|
|
973
|
+
});
|
|
974
|
+
});
|
|
975
|
+
});
|
|
976
|
+
|
|
977
|
+
describe('#isValidEAN13', function () {
|
|
978
|
+
for (const validEAN of [
|
|
979
|
+
'9780345418913',
|
|
980
|
+
'4006381333931',
|
|
981
|
+
'4012345678901',
|
|
982
|
+
'4012028630066',
|
|
983
|
+
]) {
|
|
984
|
+
it(`should accept ${validEAN}`, function () {
|
|
985
|
+
expect(isValidEAN13(validEAN)).to.eql(true);
|
|
986
|
+
});
|
|
987
|
+
|
|
988
|
+
it(`should only accept full matches (testing with variations of ${validEAN})`, function () {
|
|
989
|
+
expect(isValidISSN(` ${validEAN}`)).to.eql(false);
|
|
990
|
+
expect(isValidISSN(` ${validEAN} `)).to.eql(false);
|
|
991
|
+
expect(isValidISSN(`${validEAN}$`)).to.eql(false);
|
|
992
|
+
expect(isValidISSN(`!${validEAN}`)).to.eql(false);
|
|
993
|
+
});
|
|
994
|
+
}
|
|
995
|
+
|
|
996
|
+
for (const invalidEAN of [
|
|
997
|
+
'9780345418914',
|
|
998
|
+
'1234567890123',
|
|
999
|
+
'08981912910',
|
|
1000
|
+
'07890950160',
|
|
1001
|
+
]) {
|
|
1002
|
+
it(`should reject ${invalidEAN}`, function () {
|
|
1003
|
+
expect(isValidEAN13(invalidEAN)).to.eql(false);
|
|
1004
|
+
});
|
|
1005
|
+
}
|
|
1006
|
+
|
|
1007
|
+
describe('should handle any given string without throwing an exception', function () {
|
|
1008
|
+
it('with ASCII input', function () {
|
|
1009
|
+
fc.assert(
|
|
1010
|
+
fc.property(fc.string(), (text) => {
|
|
1011
|
+
expect(isValidEAN13(text)).to.be.oneOf([true, false]);
|
|
1012
|
+
}),
|
|
1013
|
+
);
|
|
1014
|
+
});
|
|
1015
|
+
|
|
1016
|
+
it('with unicode input', function () {
|
|
1017
|
+
fc.assert(
|
|
1018
|
+
fc.property(fc.fullUnicodeString(), (text) => {
|
|
1019
|
+
expect(isValidEAN13(text)).to.be.oneOf([true, false]);
|
|
1020
|
+
}),
|
|
1021
|
+
);
|
|
1022
|
+
});
|
|
1023
|
+
});
|
|
1024
|
+
});
|
|
1025
|
+
|
|
1026
|
+
describe('#isValidISSN', function () {
|
|
1027
|
+
for (const validISSN of [
|
|
1028
|
+
'2049-3630',
|
|
1029
|
+
'1234-5679',
|
|
1030
|
+
'12345679',
|
|
1031
|
+
'0975-1025',
|
|
1032
|
+
'09751025',
|
|
1033
|
+
'0096-9621',
|
|
1034
|
+
'0378-5955',
|
|
1035
|
+
'1050-124X',
|
|
1036
|
+
'1050124X',
|
|
1037
|
+
'1050-124x',
|
|
1038
|
+
'1050124x',
|
|
1039
|
+
'0317-8471',
|
|
1040
|
+
'0001-253x',
|
|
1041
|
+
]) {
|
|
1042
|
+
it(`should accept ${validISSN}`, function () {
|
|
1043
|
+
expect(isValidISSN(validISSN)).to.eql(true);
|
|
1044
|
+
});
|
|
1045
|
+
|
|
1046
|
+
it(`should only accept full matches (testing with variations of ${validISSN})`, function () {
|
|
1047
|
+
expect(isValidISSN(` ${validISSN}`)).to.eql(false);
|
|
1048
|
+
expect(isValidISSN(` ${validISSN} `)).to.eql(false);
|
|
1049
|
+
expect(isValidISSN(`${validISSN}$`)).to.eql(false);
|
|
1050
|
+
expect(isValidISSN(`!${validISSN}`)).to.eql(false);
|
|
1051
|
+
});
|
|
1052
|
+
}
|
|
1053
|
+
|
|
1054
|
+
for (const invalidISSN of [
|
|
1055
|
+
'1234-567X',
|
|
1056
|
+
'1234-567x',
|
|
1057
|
+
'1234567x',
|
|
1058
|
+
'1234567X',
|
|
1059
|
+
'1234-567A',
|
|
1060
|
+
'123-4567',
|
|
1061
|
+
'0378-595X',
|
|
1062
|
+
'1234-12340000',
|
|
1063
|
+
'some random text but no ISSN',
|
|
1064
|
+
]) {
|
|
1065
|
+
it(`should reject ${invalidISSN}`, function () {
|
|
1066
|
+
expect(isValidISSN(invalidISSN)).to.eql(false);
|
|
1067
|
+
});
|
|
1068
|
+
}
|
|
1069
|
+
|
|
1070
|
+
describe('should handle any given string without throwing an exception', function () {
|
|
1071
|
+
it('with ASCII input', function () {
|
|
1072
|
+
fc.assert(
|
|
1073
|
+
fc.property(fc.string(), (text) => {
|
|
1074
|
+
expect(isValidISSN(text)).to.be.oneOf([true, false]);
|
|
1075
|
+
}),
|
|
1076
|
+
);
|
|
1077
|
+
});
|
|
1078
|
+
|
|
1079
|
+
it('with unicode input', function () {
|
|
1080
|
+
fc.assert(
|
|
1081
|
+
fc.property(fc.fullUnicodeString(), (text) => {
|
|
1082
|
+
expect(isValidISSN(text)).to.be.oneOf([true, false]);
|
|
1083
|
+
}),
|
|
1084
|
+
);
|
|
1085
|
+
});
|
|
1086
|
+
});
|
|
1087
|
+
});
|