fix(web): validate avatar URL before saving - #1172
Open
ieuforu wants to merge 1 commit into
Open
Conversation
- Add URL format validation (must be http/https protocol) - Verify URL loads as a valid image via Image() probe - Show error toast on validation failure - Use Button loading state during validation - Add i18n keys for en/zh/ja locales Closes felinics#1149
Member
|
P1 — 无法再清空头像(回归)。 两个弹窗原本都允许把输入框清空来移除头像:detail.vue:609-616 的 watcher 收到空串后会保存 avatar_url: undefined,profile 同理。现在 isValidUrl('') 直接抛异常返回 false,空输入被拦截并报“请输入有效的图片地址”。这是唯一的移除头像入口(页面上没有单独的删除按钮),等于此 PR 之后 Bot 和个人头像都设了就删不掉。修法很简单:空值跳过校验直接通过。 P2 — Image() 探测无超时。 isImageUrl 在目标服务器挂起(不响应也不断开)时 Promise 永不 resolve,确认按钮永久卡在 loading。只能关掉重开弹窗恢复。建议加一个 8~10 秒的 setTimeout 竞速。 P2 — "Closes #1149" 范围不符。 issue 的期望有三条:保存前校验(本 PR 满足)、失败明确提示(满足)、评估服务端代理/缓存(完全没做)。而且本 PR 纯前端——后端 users/bots 更新接口对 avatar_url 依然零校验,直接调 API 仍可写入任意外链,issue 里“被滥用为外链加载/探测”的隐患并没有消除。合并会自动关闭 issue,把服务端那半个问题一起埋掉。建议改掉 "Closes"(用 "Partially addresses"),或者由你决定是否开 follow-up。 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1149