feat(签章标识): 规范签章标识与导入合并
build.yaml / build (push) Successful in 44s

This commit is contained in:
xiaoqidun committed 2026-10-10 18:32:03 +08:00
1 parent 341ad7cd7e
commit 53769b65ab
4 files changed
+143 -48

No files matched your search

+21 -5
View File
@@ -18,7 +18,7 @@ import (
"fmt"
"math"
"strconv"
"strings"
"unicode/utf8"
)
// SignaturePageStamps 生成所选页面相同毫米坐标的印章位置并检查页内范围
@@ -142,13 +142,29 @@ func signatureWriteStamps(r *Reader, stamps []SignatureStamp, seal bool) ([]Sign
return result, nil
}
// signatureWriteIDValid 检查可互通的签章标识字符
// signatureWriteIDValid 按XML 1.0的NCName规则校验签章标识
// 入参: id 标识
// 返回: bool 是否有效
func signatureWriteIDValid(id string) bool {
return id != "" && len(id) <= 128 && strings.IndexFunc(id, func(c rune) bool {
return !(c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' || c >= '0' && c <= '9' || c == '_' || c == '-' || c == '.')
}) == -1
if id == "" || !utf8.ValidString(id) {
return false
}
for i, c := range id {
if c == '_' || c >= 'A' && c <= 'Z' || c >= 'a' && c <= 'z' ||
c >= 0xC0 && c <= 0xD6 || c >= 0xD8 && c <= 0xF6 ||
c >= 0xF8 && c <= 0x2FF || c >= 0x370 && c <= 0x37D ||
c >= 0x37F && c <= 0x1FFF || c >= 0x200C && c <= 0x200D ||
c >= 0x2070 && c <= 0x218F || c >= 0x2C00 && c <= 0x2FEF ||
c >= 0x3001 && c <= 0xD7FF || c >= 0xF900 && c <= 0xFDCF ||
c >= 0xFDF0 && c <= 0xFFFD || c >= 0x10000 && c <= 0xEFFFF {
continue
}
if i == 0 || !(c == '-' || c == '.' || c >= '0' && c <= '9' ||
c == 0xB7 || c >= 0x300 && c <= 0x36F || c >= 0x203F && c <= 0x2040) {
return false
}
}
return true
}
// signatureWriteBoxValid 判断印章区域是否有限且尺寸为正