Skip to content

使用 API 插入行级元素嵌套 HTML 实体时丢失实体内容 #6714

Closed
@Zuoqiu-Yingyi

Description

@Zuoqiu-Yingyi
Contributor

该问题是否已经被报告过了? Is there an existing issue for this?

  • 我已经搜索了 Issues,没有发现类似问题
    I have searched the existing issues

该问题是否能够在默认主题(daylight/midnight)下重现? Can the issue be reproduced with the default theme (daylight/midnight)?

  • 我能够在默认主题下重现该问题
    I was able to reproduce the issue with the default theme

描述问题 Describe the problem

数据库 markdown 字段与 API getBlockKramdown, exportMdContent 返回的内容中行内元素

  • < 被转义为 &lt;
  • > 被转义为 &gt;
  • & 被转义为 &amp;
  • " 被转义为 &quot;

但是使用 API /api/block/* 增改块时若在行内元素中使用这些转义符, 增改的块将丢失原字符

比如插入/更新内容为 **11&lt;22&gt;33&amp;44&quot;55**, 插入/更新后的块只显示 **1122334455**

这样会导致 导出/查询 → 处理 → 导入 自动化流程无法正常进行

期待的结果 Expected result

输出时与输入时对这些符号处理原则保持一致

解决方案 1

输出时(数据库 markdown 字段与 API getBlockKramdown 返回的内容)行内元素使用 \ 转义, 比如使用 \< 转义 <

解决方案 2

输入时(使用 API /api/block/* 增改块)行内元素同时支持解析 &lt; 等方式转义的字符

截屏或者录屏演示 Screenshot or screen recording presentation

No response

版本环境 Version environment

- Version: 2.5.1
- Operating System: 
- Browser (if used):

日志文件 Log file

无有效信息输出

更多信息 More information

No response

Activity

changed the title [-]数据库 `markdown` 字段, API `getBlockKramdown & exportMdContent` 与 API `/api/block/*` 中对行内元素转义符号处理不一致[/-] [+]数据库 `markdown` 字段和 API 对行内元素转义符号处理不一致[/+] on Nov 25, 2022
self-assigned this
on Nov 25, 2022
88250

88250 commented on Nov 25, 2022

@88250
Member

我这里测试没有重现问题:

image

使用 insertBlock 插入:

image

但是使用 HTML 实体插入确实有问题:

image

我们先改进这个问题。

Zuoqiu-Yingyi

Zuoqiu-Yingyi commented on Nov 25, 2022

@Zuoqiu-Yingyi
ContributorAuthor

我这里测试没有重现问题

出问题的是行内元素内部的 HTML 转义字符, 例如这个请求体

{
  "dataType": "markdown",
  "data": "**11&lt;22&gt;33&amp;44&quot;55**",
  "id": "20211230161520-querkps"
}
88250

88250 commented on Nov 25, 2022

@88250
Member

@Zuoqiu-Yingyi 明白了,谢谢。

added this to the 2.5.2 milestone on Nov 25, 2022
changed the title [-]数据库 `markdown` 字段和 API 对行内元素转义符号处理不一致[/-] [+]API 行级元素嵌套 HTML 实体时丢失实体内容[/+] on Nov 25, 2022
changed the title [-]API 行级元素嵌套 HTML 实体时丢失实体内容[/-] [+]使用 API 插入行级元素嵌套 HTML 实体时丢失实体内容[/+] on Nov 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

    Development

    No branches or pull requests

      Participants

      @88250@Zuoqiu-Yingyi

      Issue actions

        使用 API 插入行级元素嵌套 HTML 实体时丢失实体内容 · Issue #6714 · siyuan-note/siyuan