@@ -143,7 +143,14 @@ func EditWikiPage(ctx *context.APIContext) {
143143 if form .Title == "" {
144144 newWikiName = oldWikiName
145145 } else {
146- newWikiName = wiki_service .UserTitleToWebPath ("" , form .Title )
146+ // Check if the new title is the same as the current title to avoid unnecessary conversion
147+ _ , currentTitle := wiki_service .WebPathToUserTitle (oldWikiName )
148+ if strings .TrimSpace (form .Title ) == currentTitle {
149+ // Title unchanged, keep the original WebPath to avoid encoding inconsistencies
150+ newWikiName = oldWikiName
151+ } else {
152+ newWikiName = wiki_service .UserTitleToWebPath ("" , form .Title )
153+ }
147154 }
148155
149156 if len (form .Message ) == 0 {
@@ -448,11 +455,8 @@ func ListPageRevisions(ctx *context.APIContext) {
448455 return
449456 }
450457
451- // Convert commits to API format
452- result := make ([]* api.WikiCommit , len (commitsHistory ))
453- for i := range commitsHistory {
454- result [i ] = convert .ToWikiCommit (commitsHistory [i ])
455- }
458+ // Convert commits to API format and wrap in WikiCommitList
459+ result := convert .ToWikiCommitList (commitsHistory , commitsCount )
456460
457461 ctx .SetTotalCountHeader (commitsCount )
458462 ctx .JSON (http .StatusOK , result )
@@ -519,8 +523,18 @@ func wikiContentsByEntry(ctx *context.APIContext, entry *git.TreeEntry) string {
519523// wikiContentsByName returns the contents of a wiki page, along with a boolean
520524// indicating whether the page exists. Writes to ctx if an error occurs.
521525func wikiContentsByName (ctx * context.APIContext , commit * git.Commit , wikiName wiki_service.WebPath , isSidebarOrFooter bool ) (string , string ) {
522- gitFilename := wiki_service .WebPathToGitPath (wikiName )
523- entry , err := findEntryForFile (commit , gitFilename )
526+ // Try both unescaped and escaped versions of the filename for compatibility
527+ unescaped := string (wikiName ) + ".md"
528+ gitPath := wiki_service .WebPathToGitPath (wikiName )
529+
530+ // First try the unescaped version
531+ entry , err := findEntryForFile (commit , unescaped )
532+ if err == nil && entry != nil {
533+ return wikiContentsByEntry (ctx , entry ), unescaped
534+ }
535+
536+ // If not found, try the escaped gitPath version
537+ entry , err = findEntryForFile (commit , gitPath )
524538 if err != nil {
525539 if git .IsErrNotExist (err ) {
526540 if ! isSidebarOrFooter {
@@ -531,5 +545,5 @@ func wikiContentsByName(ctx *context.APIContext, commit *git.Commit, wikiName wi
531545 }
532546 return "" , ""
533547 }
534- return wikiContentsByEntry (ctx , entry ), gitFilename
548+ return wikiContentsByEntry (ctx , entry ), gitPath
535549}
0 commit comments