Skip to content

Commit

Permalink
Merge pull request #84 from ludoux/83-version-neo_151在保存-38195774-时会卡住
Browse files Browse the repository at this point in the history
fix: 处理quote时检查下标是否合法
  • Loading branch information
ludoux authored Oct 30, 2023
2 parents 5be6aa7 + fc4993b commit 18835c7
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ jobs:
release_tag: ${{steps.tag.outputs.tag}}
goos: ${{ matrix.goos }}
goarch: ${{ matrix.goarch }}
goversion: 1.21
md5sum: FALSE
extra_files: LICENSE README.md assets/* #将这些文件一并打包
ldflags: -X "github.com/ludoux/ngapost2md/nga.DEBUG_MODE=0" -X "github.com/ludoux/ngapost2md/nga.BUILD_TS=${{ env.BUILD_TS }}" -X github.com/ludoux/ngapost2md/nga.GIT_REF=${{ github.ref }} -X github.com/ludoux/ngapost2md/nga.GIT_HASH=${{ github.sha }}
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# ngapost2md ver.[NEO_1.5.1]
# ngapost2md ver.[NEO_1.5.2]

ngapost2md 是一个将 NGA 论坛帖子转换为 Markdown 格式的工具。它支持快速爬楼并存储回复人、时间和内容,同时支持保存正文图片。

Expand Down
13 changes: 12 additions & 1 deletion nga/nga.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ var (

// 这里配置文件和传参都没法改
var (
VERSION = "1.5.1" //需要手动改
VERSION = "1.5.2" //需要手动改
BUILD_TS = "1691664141" //无需,GitHub actions会自动填写
GIT_REF = "" //无需,GitHub actions会自动填写
GIT_HASH = "" //无需,GitHub actions会自动填写
Expand Down Expand Up @@ -457,7 +457,13 @@ func (tiezi *Tiezi) fixContent(floor_i int) {
for i := 0; i < quoteCount; i++ {
//最内层的quote下标
quoteStartIndex := strings.LastIndex(cont, "[quote]")
if quoteStartIndex < 0 {
break
}
quoteEndIndex := quoteStartIndex + strings.Index(cont[quoteStartIndex:], "[/quote]")
if quoteEndIndex < 0 || quoteStartIndex >= quoteEndIndex+8 {
break
}
clip := cont[quoteStartIndex : quoteEndIndex+8]

reg_str := `(?s)\[quote\]\[pid=(\d+?),.+?Post by \[uid.*?\](.+)\[\/uid\].*?\((\d{4}.+?)\):</b>(.+?)\[/quote\]((?:\n){0,2})`
Expand Down Expand Up @@ -562,6 +568,11 @@ func (tiezi *Tiezi) fixFloorContent(startFloor_i int) {
wg.Wait()
elapsedTime := time.Since(startTime) / time.Millisecond
log.Printf("修正楼层总耗时: %dms\n", elapsedTime)
// 如果为了调试取消并行的话,上述代码均注释,换成下面的
// for i := startFloor_i; i < len(tiezi.Floors); i++ {
// log.Printf("开始修正第 %02d 楼层", i)
// tiezi.fixContent(cast.ToInt(i))
// }

}

Expand Down

0 comments on commit 18835c7

Please sign in to comment.