fix: escape angle brackets in drive comment text#632
Conversation
Change-Id: I25d05412bd0a2a9e32a517b1344533ad70cb072b
📝 WalkthroughWalkthroughThe changes implement HTML entity escaping for angle bracket characters ( Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
shortcuts/drive/drive_add_comment.go (1)
562-568:⚠️ Potential issue | 🟡 MinorLength validation runs against pre-escape text.
The 1000-char limit is enforced on
input.TextbeforeescapeCommentTextis applied. Since<→<and>→>quadruple the character count for those runes, a payload accepted here can exceed 1000 characters after escaping, potentially hitting the upstream comment length limit. Consider validating against the escaped form (or documenting that 1000 refers to pre-escape length).🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@shortcuts/drive/drive_add_comment.go` around lines 562 - 568, Validate the comment length against the escaped text instead of the raw input: call escapeCommentText(input.Text) first, then check utf8.RuneCountInString on the escaped result and return output.ErrValidation("--content element #%d text exceeds 1000 characters", index) if that exceeds 1000; update the code around the replyElements append (where escapeCommentText and input.Text are used) so the same escaped value is appended to replyElements to avoid double-escaping or inconsistent checks.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In `@shortcuts/drive/drive_add_comment.go`:
- Around line 562-568: Validate the comment length against the escaped text
instead of the raw input: call escapeCommentText(input.Text) first, then check
utf8.RuneCountInString on the escaped result and return
output.ErrValidation("--content element #%d text exceeds 1000 characters",
index) if that exceeds 1000; update the code around the replyElements append
(where escapeCommentText and input.Text are used) so the same escaped value is
appended to replyElements to avoid double-escaping or inconsistent checks.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: f84382a2-b712-4b12-a478-6fc7d0d01f8a
📒 Files selected for processing (4)
shortcuts/drive/drive_add_comment.goshortcuts/drive/drive_add_comment_test.goskills/lark-drive/SKILL.mdskills/lark-drive/references/lark-drive-add-comment.md
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #632 +/- ##
==========================================
+ Coverage 60.20% 60.38% +0.18%
==========================================
Files 407 408 +1
Lines 43340 43417 +77
==========================================
+ Hits 26091 26216 +125
+ Misses 15221 15159 -62
- Partials 2028 2042 +14 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
🚀 PR Preview Install Guide🧰 CLI updatenpm i -g https://pkg.pr.new/larksuite/cli/@larksuite/cli@d81456d9c1850edd7e0084a166f2b411041c75fa🧩 Skill updatenpx skills add larksuite/cli#fix/drive-comment-escape-angle-brackets -y -g |
Summary
Fix drive comment text handling so < and > are safely escaped before comment creation, preventing invalid comment/reply content payloads.
Changes
Test Plan
Related Issues
Summary by CodeRabbit
Bug Fixes
<and>) are now automatically escaped to prevent display issues and formatting errors.Tests
Documentation