Skip to content

Commit

Permalink
🎨 Improve ID format validation siyuan-note/siyuan#12824
Browse files Browse the repository at this point in the history
  • Loading branch information
88250 committed Oct 18, 2024
1 parent 59a8c9c commit 3a8937b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
13 changes: 9 additions & 4 deletions ast/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,10 +182,15 @@ func IsNodeIDPattern(str string) bool {
return false
}

for _, c := range idPart {
if !('0' <= c && '9' >= c) {
return false
}
// 检查时间部分的范围是否正确,比如年份为 0000-9999,月份为 01-12,日期为 01-31,小时为 00-23,分钟为 00-59,秒为 00-59
year, month, day, hour, minute, second := idPart[:4], idPart[4:6], idPart[6:8], idPart[8:10], idPart[10:12], idPart[12:14]
if "0000" > year || "9999" < year ||
"01" > month || "12" < month ||
"01" > day || "31" < day ||
"00" > hour || "23" < hour ||
"00" > minute || "59" < minute ||
"00" > second || "59" < second {
return false
}

randPart := parts[1]
Expand Down
2 changes: 1 addition & 1 deletion javascript/lute.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion javascript/lute.min.js.map

Large diffs are not rendered by default.

0 comments on commit 3a8937b

Please sign in to comment.