Skip to content

fix(id/web): accept px/integral-decimal img dimensions, warn on refused (#2180) - #3408

Merged
dezren39 merged 3 commits into
mainfrom
queue/5201-2180-img-dimension
Nov 1, 2026
Merged

dezren39 merged 3 commits into
mainfrom
queue/5201-2180-img-dimension

Conversation

@dezren39

@dezren39 dezren39 commented Nov 1, 2026 •

Copy link
Copy Markdown
Member

Fixes #2180. Queue task 5201, implementing the grammar pinned by triage task 3225.

parse_img_tag (pkgs/id/src/web/markdown.rs) used a bare u64 parse for <img> width/height, so 200px, 50%, and 200.0 sizing vanished silently on import.

  • New parse_dimension helper: trim, strip ONE trailing px suffix (ASCII case-insensitive), then a pixel integer — decimal forms only when exactly integral (200.0 -> 200, 200.5 refused). Kept: bare, padded, px/PX, integral decimals, +200, 0. Refused: percents, other units, non-integral decimals, junk.
  • Refused values now emit tracing::warn! naming the attribute and the dropped raw value instead of disappearing without a trace. All import paths inherit this (parse_linked_img_tag and the inline path both call parse_img_tag). Emitter unchanged — it already writes bare integers, matching the numeric-pixel stack (PM JSON number, editor Number(attr), node view ${width}px).

Tests (laptop, cargo test --features web --lib web::markdown): 118 passed, 0 failed, including three new tests — kept forms, refused forms, and an end-to-end width="200px" -> 200 -> re-emitted width="200" round-trip. (Fresh-worktree note: the first compile failed on the missing gitignored web/dist RustEmbed folder, pre-existing and unrelated; resolved by copying the built dist from a sibling worktree.)

CI + Codex review on this head are the next gate; the queue task is parked until both are clean.


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.

@dezren39
dezren39 requested a review from a team as a code owner November 1, 2026 07:46
@coderabbitai

coderabbitai Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 8 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 5bc877f3-59ca-4732-94bb-328d1c23146d
Commits

Reviewing files that changed from the base of the PR and between 0f4731e and f68c96e.

Files selected for processing: 1
  • pkgs/id/src/web/markdown.rs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-01T09:39:25.594888Z f68c96e New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 24e7f29b14

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread pkgs/id/src/web/markdown.rs Resolved
…annot panic parse_dimension

Codex P2 on PR #3408: the str slice at len()-2 to test the px suffix panics when the offset falls inside a multibyte UTF-8 char (e.g. fullwidth digits in width). Test the last two bytes instead; when they are ASCII p/x the slice offset is a char boundary. Adds fullwidth-digit cases to the refused-forms test.
@dezren39

dezren39 commented Nov 1, 2026

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7877bcc4bf

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread pkgs/id/src/web/markdown.rs Resolved
The f64 fallback rounded inexact decimals (199.99999999999999 -> 200) and overflowed past u64::MAX. parse_integral_decimal now normalizes digit/exponent textually with checked u64 parsing: exactly-integral decimals keep their exact value (incl. u64::MAX spelled as a decimal), inexact or out-of-range forms are refused and warned on by the caller. Regression test covers both refusals and both exact acceptances.
@dezren39
dezren39 merged commit 199d9f2 into main Nov 1, 2026
1 check passed
@dezren39
dezren39 deleted the queue/5201-2180-img-dimension branch November 1, 2026 09:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant