fix(vue-renderless/file-upload): accept 支持 video/*、audio/* 通配符 (fixes #4237)#4239
fix(vue-renderless/file-upload): accept 支持 video/*、audio/* 通配符 (fixes #4237)#4239xuxiao1797 wants to merge 1 commit into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
WalkthroughUpdated file-upload accept validation to support ChangesMIME Wildcard Accept Validation
Estimated code review effort: 2 (Simple) | ~10 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 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.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/vue/src/file-upload/__tests__/accept-type.test.ts`:
- Around line 14-22: Add an explanatory comment at the mock object cast in
createUploadFn to justify why the `as any` escape is necessary for the
beforeUpload test setup. Make sure the comment is attached near the
`beforeUpload` call in accept-type.test.ts and references that the mock only
implements the minimal shape needed for `props`, `api.handleRemove`,
`Modal.message`, `constants`, `t`, and `state`, so the type system must be
bypassed intentionally.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: a4db0b1a-9c27-4469-832d-eba610028472
📒 Files selected for processing (2)
packages/renderless/src/file-upload/index.tspackages/vue/src/file-upload/__tests__/accept-type.test.ts
7d1b564 to
46184d7
Compare
…o/* 通配符 (fixes opentiny#4237) isAcceptType 此前仅对 image/* 走扩展名白名单校验,video/*、audio/* 会落入 正则分支,其中的通配符 * 被当作正则量词,导致 mp4、mp3 等合法文件被误拦截。 改为统一的 MIME 通配符映射,复用 FILE_TYPE.VIDEO / FILE_TYPE.AUDIO 白名单。 补充 accept 通配符单元测试,用 BeforeUploadOptions 替代 as any。 Co-authored-by: Cursor <cursoragent@cursor.com>
46184d7 to
223836d
Compare
fixes #4237
isAcceptType 此前仅对 image/* 走扩展名白名单校验,video/、audio/ 会落入 正则分支,其中的通配符 * 被当作正则量词,导致 mp4、mp3 等合法文件被误拦截。
改为统一的 MIME 通配符映射,复用 FILE_TYPE.VIDEO / FILE_TYPE.AUDIO 白名单。
PR
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Issue Number: #4237
What is the new behavior?
accept="video/" / audio/ 可正常上传对应格式文件
Does this PR introduce a breaking change?
Other information
Summary by CodeRabbit
Summary by CodeRabbit
Bug Fixes
accepthandling to correctly support MIME wildcards likevideo/*andaudio/*(in addition to existingimage/*support), ensuring only compatible files proceed and mismatches are blocked.Tests
acceptwildcard acceptance/rejection forvideo/*andaudio/*, plus existingimage/*behavior and validation of exact extensionacceptvalues (e.g.,.mp4).