Skip to content

[216_5] 实现文档页面创建不同样式文档#3121

Open
Yuki-Nagori wants to merge 2 commits intomainfrom
yuki/216_5/file
Open

[216_5] 实现文档页面创建不同样式文档#3121
Yuki-Nagori wants to merge 2 commits intomainfrom
yuki/216_5/file

Conversation

@Yuki-Nagori
Copy link
Copy Markdown
Contributor

No description provided.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Apr 9, 2026

Greptile Summary

本 PR 为启动标签页「文件」页实现了完整的 UI 框架:包含 Generic/Beamer/Book/Exam/Letter/Article 六种文档样式卡片(单击选中、双击创建)、最近文档列表占位实现,以及对应的 Scheme 层函数 new-document-with-style

  • qt_startup_tab_widget.hpp 中声明的 templatePage_ 成员在构造函数和 create_template_page() 中均未被初始化/赋值,是一个未初始化的野指针,需修复。

Confidence Score: 4/5

存在一个未初始化野指针(templatePage_),建议修复后合并

核心功能(样式卡片创建、Scheme 调用、注入防护)实现正确,整体结构清晰。但 templatePage_ 成员未初始化是一个真实缺陷,虽当前不被使用,但留在代码库中是潜在隐患,应在合并前修复。

src/Plugins/Qt/qt_startup_tab_widget.hpp 和 qt_startup_tab_widget.cpp(templatePage_ 初始化问题)

Vulnerabilities

  • onRecentDocClickedcreate_template_page 中均对路径字符串做了反斜杠和双引号转义后再拼入 Scheme 命令,有效防止基本的注入攻击。
  • createDocumentWithStyle 对样式 ID 做了白名单校验,防止恶意 styleId 注入 Scheme 代码。
  • 最近文档存储为本地 JSON 文件(AppConfigLocation),无远程数据泄露风险。
  • 无其他明显安全问题。

Important Files Changed

Filename Overview
src/Plugins/Qt/qt_startup_tab_widget.hpp templatePage_ 成员声明但从未初始化(构造函数未赋 nullptr,create_template_page 也未赋值),是一个潜在的野指针缺陷
src/Plugins/Qt/qt_file_page.cpp 新增文件页核心实现:样式卡片与最近文档 UI;validStylesstyles_ 重复维护,且新增 objectName 在主题 CSS 中无对应规则
src/Plugins/Qt/qt_file_page.hpp 新增头文件,定义 DocStyle、RecentDoc 结构体及 StyleCard、QtFilePage 类,接口设计清晰
src/Plugins/Qt/qt_startup_tab_widget.cpp 用 QtFilePage 替换旧占位页面,导航结构合理;create_template_page 未将实例赋给 templatePage_ 成员
TeXmacs/progs/startup-tab/startup-tab-file.scm 新增 Scheme 模块,new-document-with-style 使用 with-default-view + delayed 异步初始化样式;最近文档相关函数均为占位实现

Comments Outside Diff (1)

  1. src/Plugins/Qt/qt_startup_tab_widget.hpp, line 80 (link)

    P1 templatePage_ 声明但从未初始化

    templatePage_ 在头文件中声明为成员变量,但构造函数的初始化列表中没有对其初始化(未赋值 nullptr),create_template_page() 中也只使用了局部变量 page,而未将其赋给 templatePage_。这导致 templatePage_ 是一个未初始化的野指针,若后续代码尝试访问它将引发未定义行为。

    同时,create_template_page() 中应补充赋值:

    QWidget*
    QTStartupTabWidget::create_template_page () {
      templatePage_= new QTTemplatePage (this);
      templatePage_->initialize ();
      // ...
      return templatePage_;
    }

Reviews (2): Last reviewed commit: "wip" | Re-trigger Greptile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant