Closed
Description
Is there an existing issue for this?
- I have searched the existing issues
Can the issue be reproduced with the default theme (daylight/midnight)?
- I was able to reproduce the issue with the default theme
Could the issue be due to extensions?
- I've ruled out the possibility that the extension is causing the problem.
Describe the problem
经过测试,在使用 Move API 的时候,如果 previousID 的类型为 doc,可能会导致需要移动的块直接丢失。
测试样例如下:
- 首先简单实现 move api
def request(route, data, token=GLOBAL_TOKEN):
headers = {
"Authorization": f"Token {token}",
"Content-Type": "application/json",
}
response = requests.post(base_url + route, headers=headers, data=json.dumps(data))
if response.ok:
return response.json()
else:
return None
def moveBlock(id, previousID=None, parentID=None):
data = {
"id": id,
"previousID": previousID,
"parentID": parentID
}
return request('/api/block/moveBlock', data)
src = '20230415154400-wum1b1x'
dst = '20230415142506-jtkp8vu'
moveBlock(src, previousID=dst)
- 块直接丢失
{'code': 0,
'msg': '',
'data': [{'doOperations': [{'action': 'move',
'data': None,
'id': '20230415154400-wum1b1x',
'parentID': '',
'previousID': '20230415142506-jtkp8vu',
'nextID': '',
'retData': None,
'blockIDs': None,
'deckID': '',
'srcIDs': None,
'name': '',
'type': ''}],
'undoOperations': None}]}
Expected result
可以抛出错误甚至软件崩溃都在可接受范围内,但是不能无声无息直接把块弄没了,什么提示也没有。
Screenshot or screen recording presentation
No response
Version environment
- Version: 2.8.4
- Operating System: Windows 10
- Browser (if used): 无,使用的是思源桌面版
Log file
Log 文件什么反应也没有
I 2023/04/15 16:00:40 repository.go:1077: synced data repo [provider=0, ufc=1, dfc=1, ucc=1, dcc=0, ub=44 kB, db=82 kB] in [1.52s]
I 2023/04/15 16:08:41 repository.go:1077: synced data repo [provider=0, ufc=0, dfc=1, ucc=0, dcc=0, ub=0 B, db=82 kB] in [0.23s]
I 2023/04/15 16:14:04 repository.go:1077: synced data repo [provider=0, ufc=1, dfc=1, ucc=1, dcc=0, ub=44 kB, db=82 kB] in [1.56s]
I 2023/04/15 16:15:25 repository.go:1077: synced data repo [provider=0, ufc=1, dfc=1, ucc=1, dcc=0, ub=44 kB, db=82 kB] in [1.45s]
More information
No response
Metadata
Metadata
Assignees
Type
Projects
Relationships
Development
No branches or pull requests
Activity
[-]「安全隐患」Move API 存在块丢失的风险[/-][+]Improve API `moveBlock` parameter `previousID` compatibility[/+][-]Improve API `moveBlock` parameter `previousID` compatibility[/-][+]Check of API `moveBlock` parameter `previousID`[/+][-]Check of API `moveBlock` parameter `previousID`[/-][+]Check the validity of the API `moveBlock` parameter `previousID`[/+]🎨 Check the validity of the API `moveBlock` parameter `previousID` Fix …