@@ -58,10 +58,10 @@ func NewWikiPage(ctx *context.APIContext) {
5858 return
5959 }
6060
61- wikiName := wiki_service .NormalizeWikiName ( form .Title )
61+ wikiName := wiki_service .UserTitleToWebPath ( "" , form .Title )
6262
6363 if len (form .Message ) == 0 {
64- form .Message = fmt .Sprintf ("Add '%s' " , form .Title )
64+ form .Message = fmt .Sprintf ("Add %q " , form .Title )
6565 }
6666
6767 content , err := base64 .StdEncoding .DecodeString (form .ContentBase64 )
@@ -85,7 +85,7 @@ func NewWikiPage(ctx *context.APIContext) {
8585 wikiPage := getWikiPage (ctx , wikiName )
8686
8787 if ! ctx .Written () {
88- notification .NotifyNewWikiPage (ctx , ctx .Doer , ctx .Repo .Repository , wikiName , form .Message )
88+ notification .NotifyNewWikiPage (ctx , ctx .Doer , ctx .Repo .Repository , string ( wikiName ) , form .Message )
8989 ctx .JSON (http .StatusCreated , wikiPage )
9090 }
9191}
@@ -127,15 +127,15 @@ func EditWikiPage(ctx *context.APIContext) {
127127
128128 form := web .GetForm (ctx ).(* api.CreateWikiPageOptions )
129129
130- oldWikiName := wiki_service .NormalizeWikiName (ctx .Params (":pageName" ))
131- newWikiName := wiki_service .NormalizeWikiName ( form .Title )
130+ oldWikiName := wiki_service .WebPathFromRequest (ctx .Params (":pageName" ))
131+ newWikiName := wiki_service .UserTitleToWebPath ( "" , form .Title )
132132
133133 if len (newWikiName ) == 0 {
134134 newWikiName = oldWikiName
135135 }
136136
137137 if len (form .Message ) == 0 {
138- form .Message = fmt .Sprintf ("Update '%s' " , newWikiName )
138+ form .Message = fmt .Sprintf ("Update %q " , newWikiName )
139139 }
140140
141141 content , err := base64 .StdEncoding .DecodeString (form .ContentBase64 )
@@ -153,14 +153,12 @@ func EditWikiPage(ctx *context.APIContext) {
153153 wikiPage := getWikiPage (ctx , newWikiName )
154154
155155 if ! ctx .Written () {
156- notification .NotifyEditWikiPage (ctx , ctx .Doer , ctx .Repo .Repository , newWikiName , form .Message )
156+ notification .NotifyEditWikiPage (ctx , ctx .Doer , ctx .Repo .Repository , string ( newWikiName ) , form .Message )
157157 ctx .JSON (http .StatusOK , wikiPage )
158158 }
159159}
160160
161- func getWikiPage (ctx * context.APIContext , title string ) * api.WikiPage {
162- title = wiki_service .NormalizeWikiName (title )
163-
161+ func getWikiPage (ctx * context.APIContext , wikiName wiki_service.WebPath ) * api.WikiPage {
164162 wikiRepo , commit := findWikiRepoCommit (ctx )
165163 if wikiRepo != nil {
166164 defer wikiRepo .Close ()
@@ -170,7 +168,7 @@ func getWikiPage(ctx *context.APIContext, title string) *api.WikiPage {
170168 }
171169
172170 // lookup filename in wiki - get filecontent, real filename
173- content , pageFilename := wikiContentsByName (ctx , commit , title , false )
171+ content , pageFilename := wikiContentsByName (ctx , commit , wikiName , false )
174172 if ctx .Written () {
175173 return nil
176174 }
@@ -196,7 +194,7 @@ func getWikiPage(ctx *context.APIContext, title string) *api.WikiPage {
196194 }
197195
198196 return & api.WikiPage {
199- WikiPageMetaData : convert .ToWikiPageMetaData (title , lastCommit , ctx .Repo .Repository ),
197+ WikiPageMetaData : convert .ToWikiPageMetaData (wikiName , lastCommit , ctx .Repo .Repository ),
200198 ContentBase64 : content ,
201199 CommitCount : commitsCount ,
202200 Sidebar : sidebarContent ,
@@ -233,7 +231,7 @@ func DeleteWikiPage(ctx *context.APIContext) {
233231 // "404":
234232 // "$ref": "#/responses/notFound"
235233
236- wikiName := wiki_service .NormalizeWikiName (ctx .Params (":pageName" ))
234+ wikiName := wiki_service .WebPathFromRequest (ctx .Params (":pageName" ))
237235
238236 if err := wiki_service .DeleteWikiPage (ctx , ctx .Doer , ctx .Repo .Repository , wikiName ); err != nil {
239237 if err .Error () == "file does not exist" {
@@ -244,7 +242,7 @@ func DeleteWikiPage(ctx *context.APIContext) {
244242 return
245243 }
246244
247- notification .NotifyDeleteWikiPage (ctx , ctx .Doer , ctx .Repo .Repository , wikiName )
245+ notification .NotifyDeleteWikiPage (ctx , ctx .Doer , ctx .Repo .Repository , string ( wikiName ) )
248246
249247 ctx .Status (http .StatusNoContent )
250248}
@@ -316,7 +314,7 @@ func ListWikiPages(ctx *context.APIContext) {
316314 ctx .Error (http .StatusInternalServerError , "GetCommit" , err )
317315 return
318316 }
319- wikiName , err := wiki_service .FilenameToName (entry .Name ())
317+ wikiName , err := wiki_service .GitPathToWebPath (entry .Name ())
320318 if err != nil {
321319 if repo_model .IsErrWikiInvalidFileName (err ) {
322320 continue
@@ -361,7 +359,7 @@ func GetWikiPage(ctx *context.APIContext) {
361359 // "$ref": "#/responses/notFound"
362360
363361 // get requested pagename
364- pageName := wiki_service .NormalizeWikiName (ctx .Params (":pageName" ))
362+ pageName := wiki_service .WebPathFromRequest (ctx .Params (":pageName" ))
365363
366364 wikiPage := getWikiPage (ctx , pageName )
367365 if ! ctx .Written () {
@@ -411,7 +409,7 @@ func ListPageRevisions(ctx *context.APIContext) {
411409 }
412410
413411 // get requested pagename
414- pageName := wiki_service .NormalizeWikiName (ctx .Params (":pageName" ))
412+ pageName := wiki_service .WebPathFromRequest (ctx .Params (":pageName" ))
415413 if len (pageName ) == 0 {
416414 pageName = "Home"
417415 }
@@ -502,9 +500,9 @@ func wikiContentsByEntry(ctx *context.APIContext, entry *git.TreeEntry) string {
502500
503501// wikiContentsByName returns the contents of a wiki page, along with a boolean
504502// indicating whether the page exists. Writes to ctx if an error occurs.
505- func wikiContentsByName (ctx * context.APIContext , commit * git.Commit , wikiName string , isSidebarOrFooter bool ) (string , string ) {
506- pageFilename := wiki_service .NameToFilename (wikiName )
507- entry , err := findEntryForFile (commit , pageFilename )
503+ func wikiContentsByName (ctx * context.APIContext , commit * git.Commit , wikiName wiki_service. WebPath , isSidebarOrFooter bool ) (string , string ) {
504+ gitFilename := wiki_service .WebPathToGitPath (wikiName )
505+ entry , err := findEntryForFile (commit , gitFilename )
508506 if err != nil {
509507 if git .IsErrNotExist (err ) {
510508 if ! isSidebarOrFooter {
@@ -515,5 +513,5 @@ func wikiContentsByName(ctx *context.APIContext, commit *git.Commit, wikiName st
515513 }
516514 return "" , ""
517515 }
518- return wikiContentsByEntry (ctx , entry ), pageFilename
516+ return wikiContentsByEntry (ctx , entry ), gitFilename
519517}
0 commit comments