Make sure that values are IP addresses/ranges
This commit adds safeguarding for invalid IP address/range values.
This commit is contained in:
parent
c1caa62c5d
commit
0dafa28150
2 changed files with 16 additions and 0 deletions
|
@ -28,6 +28,11 @@ Contributors
|
|||
Changes
|
||||
=======
|
||||
|
||||
0.2.1 - to be released
|
||||
----------------------
|
||||
|
||||
* fix handling of invalid IP address/range values
|
||||
|
||||
0.2.0 - 2016-05-04
|
||||
------------------
|
||||
|
||||
|
|
|
@ -52,6 +52,17 @@ class IPXRefRole(XRefRole):
|
|||
super(IPXRefRole, self).__init__(
|
||||
innernodeclass=innernodeclass, **kwargs)
|
||||
|
||||
def __call__(self, typ, rawtext, text, lineno, inliner,
|
||||
options={}, content=[]):
|
||||
try:
|
||||
Network(text)
|
||||
except ValueError as e:
|
||||
env = inliner.document.settings.env
|
||||
env.warn(env.docname, "invalid ip address/range %s" % text, lineno)
|
||||
return [nodes.literal(text, text), []]
|
||||
return super(IPXRefRole, self).__call__(
|
||||
typ, rawtext, text, lineno, inliner, options, content)
|
||||
|
||||
def process_link(self, env, refnode, has_explicit_title, title, target):
|
||||
domaindata = env.domaindata['ip']
|
||||
domaindata[self.method][target] = (target, refnode)
|
||||
|
|
Loading…
Reference in a new issue