Skip to content

schema.org format parses durations incorrectly #705

Closed

Description

@drawmeanelephant

Suggested labels: bug, area: cli


Discovery audit finding M8 (medium) — cooklang/cookcli @ 7c2f48b (v0.38.1), audited 2026-10-12. Repro verified.

Summary

The schema.org format parses durations wrong.

Where

crates/format/src/schema.rs:173-202 (extract_number concatenates all digits; contains("hour") checked first).

Repro

  • prep time: 1 hour 30 minutes → "prepTime": "PT130H" (should be PT1H30M)
  • 1.5 hours → PT15H (10×)
  • cook time: 2 days → PT2M

Expected

Correct ISO 8601 durations (PT1H30M, PT1.5H, P2D).

Actual

Digits are concatenated and the unit is guessed wrong (PT130H, PT15H, PT2M).

Acceptance criteria (red → green)

  • Red: the repro emits "prepTime": "PT130H".
  • Green: the repro emits "prepTime": "PT1H30M" (and PT1.5H / P2D for the other two).

Verification

Executed repro.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions