File: unknownurl.py

package info (click to toggle)
linkchecker 10.6.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,132 kB
  • sloc: python: 13,154; makefile: 134; sh: 71; xml: 36; sql: 20; javascript: 19; php: 2
file content (476 lines) | stat: -rw-r--r-- 14,252 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
# Copyright (C) 2001-2014 Bastian Kleineidam
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
"""
Handle uncheckable URLs.
"""

import re
from . import urlbase


class UnknownUrl(urlbase.UrlBase):
    """Handle unknown or just plain broken URLs."""

    def build_url(self):
        """Only logs that this URL is unknown."""
        super().build_url()
        if self.is_ignored():
            self.add_info(
                _("%(scheme)s URL ignored.") % {"scheme": self.scheme.capitalize()}
            )
            self.set_result(_("ignored"))
        else:
            self.set_result(_("URL is unrecognized or has invalid syntax"), valid=False)

    def is_ignored(self):
        """Return True if this URL scheme is ignored."""
        return is_unknown_scheme(self.scheme)

    def can_get_content(self):
        """Unknown URLs have no content.

        @return: False
        @rtype: bool
        """
        return False


# do not edit anything below since these entries are generated from
# scripts/update_iana_uri_schemes.sh
# DO NOT REMOVE

# from https://www.iana.org/assignments/uri-schemes/uri-schemes.xhtml
ignored_schemes_permanent = r"""
|aaa        # Diameter Protocol
|aaas       # Diameter Protocol with Secure Transport
|about      # about
|acap       # application configuration access protocol
|acct       # acct
|cap        # Calendar Access Protocol
|cid        # content identifier
|coap       # coap
|coap\+tcp  # coap+tcp (see [reviewer notes])
|coap\+ws   # coap+ws (see [reviewer notes])
|coaps      # coaps
|coaps\+tcp # coaps+tcp (see [reviewer notes])
|coaps\+ws  # coaps+ws (see [reviewer notes])
|crid       # TV-Anytime Content Reference Identifier
|data       # data
|dav        # dav
|dict       # dictionary service protocol
|dns        # Domain Name System
|doi        # doi
|dtn        # DTNRG research and development
|example    # example
|geo        # Geographic Locations
|go         # go
|gopher     # The Gopher Protocol
|h323       # H.323
|iax        # Inter-Asterisk eXchange Version 2
|icap       # Internet Content Adaptation Protocol
|im         # Instant Messaging
|imap       # internet message access protocol
|info       # Information Assets with Identifiers in Public Namespaces. [RFC4452] (section 3) defines an "info" registry of public namespaces, which is maintained by NISO and can be accessed from [http://info-uri.info/].
|ipn        # ipn
|ipp        # Internet Printing Protocol
|ipps       # Internet Printing Protocol over HTTPS
|iris       # Internet Registry Information Service
|iris\.beep # iris.beep
|iris\.lwz  # iris.lwz
|iris\.xpc  # iris.xpc
|iris\.xpcs # iris.xpcs
|jabber     # jabber
|ldap       # Lightweight Directory Access Protocol
|leaptofrogans # leaptofrogans
|mid        # message identifier
|msrp       # Message Session Relay Protocol
|msrps      # Message Session Relay Protocol Secure
|mt         # Matter protocol on-boarding payloads that are encoded for use in QR Codes and/or NFC Tags
|mtqp       # Message Tracking Query Protocol
|mupdate    # Mailbox Update (MUPDATE) Protocol
|news       # USENET news
|nfs        # network file system protocol
|ni         # ni
|nih        # nih
|nntp       # USENET news using NNTP access
|opaquelocktoken # opaquelocktokent
|pkcs11     # PKCS#11
|pop        # Post Office Protocol v3
|pres       # Presence
|reload     # reload
|rtsp       # Real-Time Streaming Protocol (RTSP)
|rtsps      # Real-Time Streaming Protocol (RTSP) over TLS
|rtspu      # Real-Time Streaming Protocol (RTSP) over unreliable datagram transport
|service    # service location
|session    # session
|shttp      # Secure Hypertext Transfer Protocol
|sieve      # ManageSieve Protocol
|sip        # session initiation protocol
|sips       # secure session initiation protocol
|sms        # Short Message Service
|snmp       # Simple Network Management Protocol
|soap\.beep # soap.beep
|soap\.beeps # soap.beeps
|stun       # stun
|stuns      # stuns
|tag        # tag
|tel        # telephone
|telnet     # Reference to interactive sessions
|tftp       # Trivial File Transfer Protocol
|thismessage # multipart/related relative reference resolution
|tip        # Transaction Internet Protocol
|tn3270     # Interactive 3270 emulation sessions
|turn       # turn
|turns      # turns
|tv         # TV Broadcasts
|urn        # Uniform Resource Names
|vemmi      # versatile multimedia interface
|vnc        # Remote Framebuffer Protocol
|ws         # WebSocket connections
|wss        # Encrypted WebSocket connections
|xcon       # xcon
|xcon\-userid # xcon-userid
|xmlrpc\.beep # xmlrpc.beep
|xmlrpc\.beeps # xmlrpc.beeps
|xmpp       # Extensible Messaging and Presence Protocol
|z39\.50r   # Z39.50 Retrieval
|z39\.50s   # Z39.50 Session
"""

ignored_schemes_provisional = r"""
|acd        # acd
|acr        # acr
|adiumxtra  # adiumxtra
|adt        # adt
|afp        # afp
|afs        # Andrew File System global file names
|aim        # aim
|amss       # amss
|android    # android
|appdata    # appdata
|apt        # apt
|ar         # ar
|ari        # ari
|ark        # ark
|at         # at (see [reviewer notes])
|attachment # attachment
|aw         # aw
|barion     # barion
|beshare    # beshare
|bitcoin    # bitcoin
|bitcoincash # bitcoincash
|bl         # bluetooth (shortened)
|blob       # blob
|bluetooth  # bluetooth
|bolo       # bolo
|brid       # brid
|browserext # browserext
|cabal      # cabal
|calculator # calculator
|callto     # callto
|cast       # cast
|casts      # casts
|chrome     # chrome
|chrome\-extension # chrome-extension
|com\-eventbrite\-attendee # com-eventbrite-attendee
|content    # content
|content\-type # content-type
|cstr       # cstr
|cvs        # cvs
|dab        # dab
|dat        # dat
|dhttp      # dhttp (see [reviewer notes])
|diaspora   # diaspora
|did        # did
|dis        # dis
|dlna\-playcontainer # dlna-playcontainer
|dlna\-playsingle # dlna-playsingle
|dntp       # dntp
|dpp        # dpp
|drm        # drm
|dtmi       # dtmi
|dvb        # dvb
|dvx        # dvx
|dweb       # dweb
|ed2k       # ed2k
|eid        # eid
|elsi       # elsi
|embedded   # embedded
|ens        # ens
|ethereum   # ethereum
|facetime   # facetime
|feed       # feed
|feedready  # feedready
|fido       # fido
|finger     # finger
|first\-run\-pen\-experience # first-run-pen-experience
|fish       # fish
|fm         # fm
|fuchsia\-pkg # fuchsia-pkg
|gg         # gg
|git        # git
|gitoid     # gitoid
|gizmoproject # gizmoproject
|graph      # graph
|gtalk      # gtalk
|ham        # ham
|hcap       # hcap
|hcp        # hcp
|hs20       # hs20
|hxxp       # hxxp
|hxxps      # hxxps
|hydrazone  # hydrazone
|hyper      # hyper
|icon       # icon
|ilstring   # ilstring
|iotdisco   # iotdisco
|ipfs       # ipfs
|ipns       # ipns
|irc        # irc
|irc6       # irc6
|ircs       # ircs
|isostore   # isostore
|itms       # itms
|jar        # jar
|jms        # Java Message Service
|keyparc    # keyparc
|lastfm     # lastfm
|lbry       # lbry
|ldaps      # ldaps
|lid        # lid
|lorawan    # lorawan
|lpa        # lpa
|lvlt       # lvlt
|machineProvisioningProgressReporter # Windows Autopilot Modern Device Management status updates
|magnet     # magnet
|maps       # maps
|market     # market
|matrix     # matrix
|message    # message
|microsoft\.windows\.camera # microsoft.windows.camera
|microsoft\.windows\.camera\.multipicker # microsoft.windows.camera.multipicker
|microsoft\.windows\.camera\.picker # microsoft.windows.camera.picker
|mms        # mms
|mongodb    # mongodb
|moz        # moz
|ms\-access # ms-access
|ms\-appinstaller # ms-appinstaller
|ms\-browser\-extension # ms-browser-extension
|ms\-calculator # ms-calculator
|ms\-drive\-to # ms-drive-to
|ms\-enrollment # ms-enrollment
|ms\-excel  # ms-excel
|ms\-eyecontrolspeech # ms-eyecontrolspeech
|ms\-gamebarservices # ms-gamebarservices
|ms\-gamingoverlay # ms-gamingoverlay
|ms\-getoffice # ms-getoffice
|ms\-help   # ms-help
|ms\-infopath # ms-infopath
|ms\-inputapp # ms-inputapp
|ms\-launchremotedesktop # ms-launchremotedesktop
|ms\-lockscreencomponent\-config # ms-lockscreencomponent-config
|ms\-media\-stream\-id # ms-media-stream-id
|ms\-meetnow # ms-meetnow
|ms\-mixedrealitycapture # ms-mixedrealitycapture
|ms\-mobileplans # ms-mobileplans
|ms\-newsandinterests # ms-newsandinterests
|ms\-officeapp # ms-officeapp
|ms\-people # ms-people
|ms\-personacard # ms-personacard
|ms\-powerpoint # ms-powerpoint
|ms\-project # ms-project
|ms\-publisher # ms-publisher
|ms\-recall # ms-recall
|ms\-remotedesktop # ms-remotedesktop
|ms\-remotedesktop\-launch # ms-remotedesktop-launch
|ms\-restoretabcompanion # ms-restoretabcompanion
|ms\-screenclip # ms-screenclip
|ms\-screensketch # ms-screensketch
|ms\-search # ms-search
|ms\-search\-repair # ms-search-repair
|ms\-secondary\-screen\-controller # ms-secondary-screen-controller
|ms\-secondary\-screen\-setup # ms-secondary-screen-setup
|ms\-settings # ms-settings
|ms\-settings\-airplanemode # ms-settings-airplanemode
|ms\-settings\-bluetooth # ms-settings-bluetooth
|ms\-settings\-camera # ms-settings-camera
|ms\-settings\-cellular # ms-settings-cellular
|ms\-settings\-cloudstorage # ms-settings-cloudstorage
|ms\-settings\-connectabledevices # ms-settings-connectabledevices
|ms\-settings\-displays\-topology # ms-settings-displays-topology
|ms\-settings\-emailandaccounts # ms-settings-emailandaccounts
|ms\-settings\-language # ms-settings-language
|ms\-settings\-location # ms-settings-location
|ms\-settings\-lock # ms-settings-lock
|ms\-settings\-nfctransactions # ms-settings-nfctransactions
|ms\-settings\-notifications # ms-settings-notifications
|ms\-settings\-power # ms-settings-power
|ms\-settings\-privacy # ms-settings-privacy
|ms\-settings\-proximity # ms-settings-proximity
|ms\-settings\-screenrotation # ms-settings-screenrotation
|ms\-settings\-wifi # ms-settings-wifi
|ms\-settings\-workplace # ms-settings-workplace
|ms\-spd    # ms-spd
|ms\-stickers # ms-stickers
|ms\-sttoverlay # ms-sttoverlay
|ms\-transit\-to # ms-transit-to
|ms\-useractivityset # ms-useractivityset
|ms\-virtualtouchpad # ms-virtualtouchpad
|ms\-visio  # ms-visio
|ms\-walk\-to # ms-walk-to
|ms\-whiteboard # ms-whiteboard
|ms\-whiteboard\-cmd # ms-whiteboard-cmd
|ms\-widgetboard # ms-widgetboard
|ms\-widgets # ms-widgets
|ms\-word   # ms-word
|msnim      # msnim
|mss        # mss
|mumble     # mumble
|mvn        # mvn
|mvrp       # mvrp      (see [reviewer notes])
|mvrps      # mvrps      (see [reviewer notes])
|notes      # notes
|num        # Namespace Utility Modules
|ocf        # ocf
|oid        # oid
|onenote    # onenote
|onenote\-cmd # onenote-cmd
|openid     # OpenID Connect
|openpgp4fpr # openpgp4fpr
|otpauth    # otpauth
|palm       # palm
|paparazzi  # paparazzi
|payto      # payto
|platform   # platform
|proxy      # proxy
|psyc       # psyc
|pttp       # pttp
|pwid       # pwid
|qb         # qb
|query      # query
|quic\-transport # quic-transport
|redis      # redis
|rediss     # rediss
|res        # res
|resource   # resource
|rmi        # rmi
|rsync      # rsync
|rtmfp      # rtmfp
|rtmp       # rtmp
|sarif      # sarif
|secondlife # query
|secret\-token # secret-token
|sftp       # query
|sgn        # sgn
|shc        # shc
|shelter    # shelter
|simpleledger # simpleledger
|simplex    # simplex
|skype      # skype
|smb        # smb
|smp        # smp
|smtp       # smtp
|soldat     # soldat
|spiffe     # spiffe
|spotify    # spotify
|ssb        # ssb
|ssh        # ssh
|starknet   # starknet
|steam      # steam
|submit     # submit
|svn        # svn
|swh        # swh
|swid       # swid (see [reviewer notes])
|swidpath   # swidpath (see [reviewer notes])
|taler      # taler
|teamspeak  # teamspeak
|teapot     # teapot
|teapots    # teapots
|teliaeid   # teliaeid
|things     # things
|tool       # tool
|udp        # udp
|unreal     # unreal
|ut2004     # ut2004
|uuid\-in\-package # uuid-in-package
|v\-event   # v-event
|ventrilo   # ventrilo
|ves        # ves
|view\-source # view-source
|vscode     # vscode
|vscode\-insiders # vscode-insiders
|vsls       # vsls
|w3         # w3 (see [reviewer notes])
|wasm       # wasm
|wasm\-js   # wasm-js
|wcr        # wcr
|web\+ap    # web+ap
|web3       # web3
|webcal     # webcal
|wifi       # wifi
|wtai       # wtai
|wyciwyg    # wyciwyg
|xfire      # xfire
|xftp       # xftp
|xrcp       # xrcp
|xri        # xri
|ymsgr      # ymsgr
"""

ignored_schemes_historical = r"""
|bb         # bb
|drop       # drop
|fax        # fax
|filesystem # filesystem
|grd        # grd
|mailserver # Access to data available from mail servers
|modem      # modem
|p1         # p1
|pack       # pack
|payment    # payment
|prospero   # Prospero Directory Service
|snews      # NNTP over SSL/TLS
|thzp       # thzp
|upt        # upt
|videotex   # videotex
|wais       # Wide Area Information Servers
|wpid       # wpid
|z39\.50    # Z39.50 information access
"""

ignored_schemes_other = r"""
|clsid      # Microsoft specific
|find       # Mozilla specific
|gemini     # Gemini protocol
|isbn       # ISBN (int. book numbers)
|javascript # JavaScript
|litecoin   # Litecoin payment
|ltclightning # Litecoin Lightning invoice
|ms\-windows\-store # Microsoft Store
|slack      # Slack Technologies client
|tg         # Telegram
|whatsapp   # WhatsApp
"""

ignored_schemes = "^({}{}{}{})$".format(
    ignored_schemes_permanent,
    ignored_schemes_provisional,
    ignored_schemes_historical,
    ignored_schemes_other,
)
ignored_schemes_re = re.compile(ignored_schemes, re.VERBOSE)

is_unknown_scheme = ignored_schemes_re.match