Skip to content

Remove attribute data-obj from marketplace package card, add attribute data-repourl, and query package information from memory#17809

Merged
Vanessa219 merged 1 commit into
siyuan-note:devfrom
TCOTC:fix/card
Jun 14, 2026
Merged

Conversation

@TCOTC

@TCOTC TCOTC commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Description / 描述

集市包卡片移除属性 data-obj、增加属性 data-name 并从内存查询包信息

修复潜在安全问题:GHSA-x88j-wgpr-h22x

修复问题:#14636 (comment)

Type of change / 变更类型

  • Bug fix
    缺陷修复
  • Refactoring
    代码重构
  • New feature
    新功能
  • Text updates or new language additions
    修改文案或增加新语言

Checklist / 检查清单

  • I have performed a self-review of my own code
    我对自己的代码进行了自我审查
  • I have full rights to the submitted code and agree to license it under this project's AGPL-3.0 license
    我拥有所提交代码的完整权利,并同意其以本项目的 AGPL-3.0 许可证授权
  • PR is submitted to the dev branch and has no merge conflicts
    PR 提交到 dev 分支,并且没有合并冲突

@TCOTC TCOTC changed the title Remove attribute data-obj from marketplace package card, add attribute data-name, and query pack information from memory Remove attribute data-obj from marketplace package card, add attribute data-name, and query package information from memory Jun 4, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the Bazaar (marketplace) UI and related kernel download-progress plumbing to avoid embedding a JSON blob (data-obj) into package cards, instead using data-name and resolving package metadata from in-memory state. This aligns with the linked security advisory and simplifies the DOM surface area used for package interactions.

Changes:

  • Kernel: adjust downloadBazaarFile to accept a packageName for progress push IDs, and propagate additional online metadata into installed package entries when an update exists.
  • Frontend: remove data-obj usage across Bazaar rendering/event handling; add data-name (and README side metadata) and re-resolve items from bazaar._data.
  • Frontend: introduce TBazaarPackageSource and add helpers for re-rendering/sorting/rendering Bazaar cards and syncing an open README view.

Reviewed changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
kernel/bazaar/readme.go Updates README file fetch to match the new downloadBazaarFile signature.
kernel/bazaar/install.go Extends download helper to accept packageName and uses it for WS progress IDs.
kernel/bazaar/installed.go Copies additional online metadata into installed packages when an update is available.
app/src/types/index.d.ts Adds TBazaarPackageSource for distinguishing bazaar/downloaded/update origins in UI.
app/src/dialog/processSystem.ts Matches download progress events against Bazaar README data-name instead of data-obj.
app/src/config/bazaar.ts Major Bazaar UI refactor: removes data-obj, adds data-name, resolves items from memory, introduces sorting/render helpers, and syncs open README state.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread app/src/config/bazaar.ts
Comment on lines +1111 to +1130
_sortPackages(packages: IBazaarItem[], sortValue: string): IBazaarItem[] {
const sorted = [...packages];
// 更新时间降序
if (sortValue === "0") {
return sorted.sort((a, b) => (b.updated < a.updated ? -1 : 1));
}
// 更新时间升序
if (sortValue === "1") {
return sorted.sort((a, b) => (b.updated < a.updated ? 1 : -1));
}
// 下载次数降序
if (sortValue === "2") {
return sorted.sort((a, b) => (b.downloads < a.downloads ? -1 : 1));
}
// 下载次数升序
if (sortValue === "3") {
return sorted.sort((a, b) => (b.downloads < a.downloads ? 1 : -1));
}
return sorted;
},

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

理论上可能出现,但实际上没有所谓

Comment thread app/src/config/bazaar.ts
Comment on lines +668 to +672
} else if (nameElement.closest('[data-type="downloaded-update"]')) {
// 更新列表
pkgSource = "update";
if (packageName) {
for (const bazaarType of ["plugins", "themes", "icons", "templates", "widgets"] as TBazaarType[]) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

直接遍历一遍很快,并且 name 在所有类型的集市包中唯一,没有必要增加 data-type

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 6 changed files in this pull request and generated 2 comments.

Comment thread app/src/config/bazaar.ts
let dataObj: IObject;
if (dataElement) {
dataObj = JSON.parse(dataElement.getAttribute("data-obj"));
const nameElement = hasClosestByAttribute(target, "data-name", undefined);
Comment thread app/src/config/bazaar.ts
Comment on lines +658 to +660
let pkgType: TBazaarType | undefined;
let pkgSource: TBazaarPackageSource | undefined;
let pkgItem: IBazaarItem;
@Vanessa219 Vanessa219 merged commit 4ac5a45 into siyuan-note:dev Jun 14, 2026
1 check passed
@Vanessa219 Vanessa219 added this to the 3.7.0 milestone Jun 14, 2026
Vanessa219 added a commit that referenced this pull request Jun 14, 2026
@Vanessa219

Copy link
Copy Markdown
Member
  • name 标识修改为 repoURL
  • 插件卸载或安装时,其余tab页面更新没有过滤搜索条件

@TCOTC

TCOTC commented Jun 14, 2026

Copy link
Copy Markdown
Contributor Author

01

更新列表和在线列表的详情页“当前版本”始终显示的是本地包版本号,应该只在已下载的列表才是本地包版本号:

video.webm

@TCOTC

TCOTC commented Jun 14, 2026

Copy link
Copy Markdown
Contributor Author

02

本地列表详情页里更新完之后没有重新渲染新的 README 内容(我手动清空了本地 README 的内容):

video.webm

@TCOTC TCOTC deleted the fix/card branch June 14, 2026 09:54
@TCOTC

TCOTC commented Jun 14, 2026

Copy link
Copy Markdown
Contributor Author

03

bazaarThemeMode 这个 id 不应该改为 bazaarSelect,命名太泛化了

@TCOTC TCOTC changed the title Remove attribute data-obj from marketplace package card, add attribute data-name, and query package information from memory Remove attribute data-obj from marketplace package card, add attribute data-repourl, and query package information from memory Jun 14, 2026
Vanessa219 added a commit that referenced this pull request Jun 14, 2026
Vanessa219 added a commit that referenced this pull request Jun 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants