Crash with the ordinal indicators `º`/`ª` in `mi`
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 88/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- rust
调研方向
从 src/canonicalize.rs 中的 split_apart_pseudo_scripts 和报告中无法通过的 MathML 示例开始。issue 包含针对单字符标识符的保护措施提案,以及一个名为 pseudo_script_single_char_mi 的回归测试;运行 cargo test 检查修复。示例不再导致崩溃且回归测试通过,即表示完成。
由索引模型根据 Issue 内容生成。
描述
In Spanish, ordinals are written with a period and the ordinal indicator: 1.º, 2.ª (U+00BA, U+00AA; not the degree sign). When the indicator comes as an mi on its own, MathCAT crashes, in any language:
<math><mn>1</mn><mo>.</mo><mi>º</mi></math>
<math><mn>1.</mn><mi>º</mi></math>
<math><mn>2</mn><mo>.</mo><mi>ª</mi></math>
All give index out of bounds at src/canonicalize.rs:404.
Cause and proposed patch: split_apart_pseudo_scripts pairs each char with the next one, so a single char gives no pairs and replace_children is called with an empty list. Tested: cargo test passes; adds the test pseudo_script_single_char_mi.
diff --git a/src/canonicalize.rs b/src/canonicalize.rs
index 1e3936f8..00a5165b 100644
--- a/src/canonicalize.rs
+++ b/src/canonicalize.rs
@@ -1520,7 +1520,8 @@ impl CanonicalizeContext {
let text = as_text(mi);
// debug!("split_apart_pseudo_scripts: start text=\"{text}\"");
- if !text.chars().any(is_pseudo_script_char) || IS_DEGREES_C_OR_F.is_match(as_str!(text)) {
+ if !text.chars().any(is_pseudo_script_char) || IS_DEGREES_C_OR_F.is_match(as_str!(text)) ||
+ text.chars().nth(1).is_none() { // a single char (e.g., "º") has nothing to split
return None;
}
@@ -7085,6 +7086,14 @@ mod canonicalize_tests {
are_strs_canonically_equal_result(test_str, target_str, &[])
}
+ #[test]
+ fn pseudo_script_single_char_mi() -> Result<()> {
+ // used to crash (index out of bounds in replace_children)
+ let test_str = "<math><mn>1</mn><mi>º</mi></math>";
+ let target_str = "<math><mrow data-changed='added'><mn>1</mn><mo data-changed='added'>⁢</mo><mi>º</mi></mrow></math>";
+ are_strs_canonically_equal_result(test_str, target_str, &[])
+ }
+
#[test]
fn prescript_only() -> Result<()> {
let test_str = "<math><msub><mtext/><mn>92</mn></msub><mi>U</mi></math>";
- 主要语言
- Rust
- 星标
- 130
- 派生
- 96
- 平均合并
- 1 天 1 小时
- 30 天内合并 PR
- 84
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
daisy/MathCAT 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 68/100
维护者通常 1 天内回复
-
discussion
难度 2/5 1-3 小时 新手友好度 70/100
维护者通常 1 天内回复
-
discussion translation
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
feature request for vector from O to A可能重新可做 @moritz-gross 于 52 天前认领,目前没有进行中的 PR。 未关闭enhancement good first issue rules rust
难度 2/5 1-3 小时 新手友好度 66/100
daisy/MathCAT#621 · 1 条评论 · 已指派 1 人 ·
维护者通常 1 天内回复
相似的 Issue
-
area: cli kind:docs priority: P3
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 88/100
swc-project/swc-ai-issues#164 ·
-
难度 2/5 1-3 小时 新手友好度 85/100
pop-os/cosmic-player#367 ·
-
good first issue help wanted
难度 2/5 1-3 小时 新手友好度 72/100
servo/rust-smallvec#873 ·