Skip to content

Commit

Permalink
feat(xml2rfc): disallow versioned I-D refs (#157)
Browse files Browse the repository at this point in the history
  • Loading branch information
strogonoff committed Mar 29, 2022
1 parent a99c2d7 commit 4084dbf
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions xml2rfc_compat/fetchers.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,22 +62,19 @@ def internet_drafts(ref: str) -> BibliographicItem:
"""
type_query = '@.type == "Internet-Draft" || @.type == "IETF"'

ref_without_prefixes = ref.replace('I-D.', '', 1).replace('draft-', '', 1)
bare_ref = remove_version(ref_without_prefixes)
bare_ref = ref.replace('I-D.', '', 1).replace('draft-', '', 1)
if bare_ref != remove_version(bare_ref):
raise RefNotFoundError("Versioned I-D references are not supported")

# Variants with/without draft- and I-D. prefixes
versionless_prefix_variants = [
prefix_variants = [
bare_ref,
f'draft-{bare_ref}',
f'I-D.draft-{bare_ref}',
]
id_query = ' || '.join([
# Variants with/without version
'@.id == "%s" || @.id like_regex "%s"' % (
versionless,
re.escape(r'%s-\d{2}' % versionless),
)
for versionless in versionless_prefix_variants
'@.id == "%s"' % variant
for variant in prefix_variants
])

results = sorted(
Expand Down

0 comments on commit 4084dbf

Please sign in to comment.