Repository navigation
fix(id/web): accept px/integral-decimal img dimensions, warn on refused (#2180) - #3408
Conversation
|
Warning Review limit reachedYou'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. View limit details
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. |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 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".
…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.
|
@codex review |
There was a problem hiding this comment.
💡 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".
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.
Fixes #2180. Queue task 5201, implementing the grammar pinned by triage task 3225.
parse_img_tag(pkgs/id/src/web/markdown.rs) used a bareu64parse for<img>width/height, so200px,50%, and200.0sizing vanished silently on import.parse_dimensionhelper: trim, strip ONE trailingpxsuffix (ASCII case-insensitive), then a pixel integer — decimal forms only when exactly integral (200.0-> 200,200.5refused). Kept: bare, padded,px/PX, integral decimals,+200,0. Refused: percents, other units, non-integral decimals, junk.tracing::warn!naming the attribute and the dropped raw value instead of disappearing without a trace. All import paths inherit this (parse_linked_img_tagand the inline path both callparse_img_tag). Emitter unchanged — it already writes bare integers, matching the numeric-pixel stack (PM JSON number, editorNumber(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-endwidth="200px"-> 200 -> re-emittedwidth="200"round-trip. (Fresh-worktree note: the first compile failed on the missing gitignoredweb/distRustEmbed 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.
Need help on this PR? Tag
@codesmith-botwith what you need.