Page MenuHomeSoftware Heritage

Make function swh.model.identifiers.parse_swhid more strict
Closed, MigratedEdits Locked

Description

Making it strict by respecting the documented grammar [1]

Currently, it misses some checks on:

  • D4461: the context qualifier (origin, visit, ...) so anybody can provide noisy swhid and be fine with it
  • D4462: whitespaces that should be refused anywhere in the string and it's not

It should also raise when those invalid SWHIDs are provided [2]

The end goal being to avoid another parsing layer in other swh users of that function.

[1] https://docs.softwareheritage.org/devel/swh-model/persistent-identifiers.html#syntax

[2] D4442#110837

Event Timeline

ardumont triaged this task as Normal priority.Nov 10 2020, 2:27 PM
ardumont created this task.
ardumont renamed this task from Make the function swh.model.identifiers.parse_swhid respect its grammar to Make the function swh.model.identifiers.parse_swhid be more strict .Nov 12 2020, 11:10 AM
ardumont updated the task description. (Show Details)
ardumont renamed this task from Make the function swh.model.identifiers.parse_swhid be more strict to Make function swh.model.identifiers.parse_swhid more strict.Nov 12 2020, 11:53 AM
ardumont updated the task description. (Show Details)
ardumont closed this task as Resolved.EditedNov 12 2020, 1:18 PM
ardumont claimed this task.

Landed, packaged in swh.model 0.8.0.
Also email sent to swh-devel as a heads up to fellow developers using that function.

closing now.