Skip to content

Commit 04a5e58

Browse files
authored
fix(server): can't edit .md source files (#1159)
* fix(server): can't edit .md source files * chore * add ignore direct link args
1 parent bbd4389 commit 04a5e58

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

internal/bootstrap/data/setting.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ func InitialSettings() []model.SettingItem {
162162
{Key: conf.OcrApi, Value: "https://openlistteam-ocr-api-server.hf.space/ocr/file/json", MigrationValue: "https://api.example.com/ocr/file/json", Type: conf.TypeString, Group: model.GLOBAL}, // TODO: This can be replace by a community-hosted endpoint, see https://github.com/OpenListTeam/ocr_api_server
163163
{Key: conf.FilenameCharMapping, Value: `{"/": "|"}`, Type: conf.TypeText, Group: model.GLOBAL},
164164
{Key: conf.ForwardDirectLinkParams, Value: "false", Type: conf.TypeBool, Group: model.GLOBAL},
165-
{Key: conf.IgnoreDirectLinkParams, Value: "sign,openlist_ts", Type: conf.TypeString, Group: model.GLOBAL},
165+
{Key: conf.IgnoreDirectLinkParams, Value: "sign,openlist_ts,raw", Type: conf.TypeString, Group: model.GLOBAL},
166166
{Key: conf.WebauthnLoginEnabled, Value: "false", Type: conf.TypeBool, Group: model.GLOBAL, Flag: model.PUBLIC},
167167
{Key: conf.SharePreview, Value: "false", Type: conf.TypeBool, Group: model.GLOBAL, Flag: model.PUBLIC},
168168
{Key: conf.ShareArchivePreview, Value: "false", Type: conf.TypeBool, Group: model.GLOBAL, Flag: model.PUBLIC},

server/handles/down.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,8 @@ func proxy(c *gin.Context, link *model.Link, file model.Obj, proxyRange bool) {
114114
link = common.ProxyRange(c, link, file.GetSize())
115115
}
116116
Writer := &common.WrittenResponseWriter{ResponseWriter: c.Writer}
117-
118-
//优先处理md文件
119-
if utils.Ext(file.GetName()) == "md" && setting.GetBool(conf.FilterReadMeScripts) {
117+
raw, _ := strconv.ParseBool(c.DefaultQuery("raw", "false"))
118+
if utils.Ext(file.GetName()) == "md" && setting.GetBool(conf.FilterReadMeScripts) && !raw {
120119
buf := bytes.NewBuffer(make([]byte, 0, file.GetSize()))
121120
w := &common.InterceptResponseWriter{ResponseWriter: Writer, Writer: buf}
122121
err = common.Proxy(w, c.Request, link, file)

0 commit comments

Comments
 (0)