package repo
import (
- "path"
+ "strings"
api "code.gitea.io/sdk/gitea"
// see https://github.com/gogits/go-gogs-client/wiki/Repositories#search-repositories
func Search(ctx *context.APIContext) {
opts := &models.SearchRepoOptions{
- Keyword: path.Base(ctx.Query("q")),
+ Keyword: strings.Trim(ctx.Query("q"), " "),
OwnerID: ctx.QueryInt64("uid"),
PageSize: convert.ToCorrectPageSize(ctx.QueryInt("limit")),
}
package user
import (
+ "strings"
+
"github.com/Unknwon/com"
api "code.gitea.io/sdk/gitea"
// Search search users
func Search(ctx *context.APIContext) {
opts := &models.SearchUserOptions{
- Keyword: ctx.Query("q"),
+ Keyword: strings.Trim(ctx.Query("q"), " "),
Type: models.UserTypeIndividual,
PageSize: com.StrTo(ctx.Query("limit")).MustInt(),
}
package routers
import (
+ "bytes"
"fmt"
+ "strings"
"github.com/Unknwon/paginater"
- "bytes"
-
"code.gitea.io/gitea/models"
"code.gitea.io/gitea/modules/base"
"code.gitea.io/gitea/modules/context"
orderBy = "created_unix DESC"
}
- keyword := ctx.Query("q")
+ keyword := strings.Trim(ctx.Query("q"), " ")
if len(keyword) == 0 {
repos, err = opts.Ranger(&models.SearchRepoOptions{
Page: page,
orderBy = "id DESC"
}
- keyword := ctx.Query("q")
+ keyword := strings.Trim(ctx.Query("q"), " ")
if len(keyword) == 0 {
users, err = opts.Ranger(&models.SearchUserOptions{OrderBy: orderBy,
Page: page,
import (
"container/list"
"path"
+ "strings"
"code.gitea.io/git"
"code.gitea.io/gitea/models"
func SearchCommits(ctx *context.Context) {
ctx.Data["PageIsCommits"] = true
- keyword := ctx.Query("q")
+ keyword := strings.Trim(ctx.Query("q"), " ")
if len(keyword) == 0 {
ctx.Redirect(ctx.Repo.RepoLink + "/commits/" + ctx.Repo.BranchName)
return
milestoneID := ctx.QueryInt64("milestone")
isShowClosed := ctx.Query("state") == "closed"
- keyword := ctx.Query("q")
+ keyword := strings.Trim(ctx.Query("q"), " ")
if bytes.Contains([]byte(keyword), []byte{0x00}) {
keyword = ""
}
// Notifications is the notifications page
func Notifications(c *context.Context) {
var (
- keyword = c.Query("q")
+ keyword = strings.Trim(c.Query("q"), " ")
status models.NotificationStatus
page = c.QueryInt("page")
perPage = c.QueryInt("perPage")
ctx.Data["SortType"] = "recentupdate"
}
- keyword := ctx.Query("q")
+ keyword := strings.Trim(ctx.Query("q"), " ")
ctx.Data["Keyword"] = keyword
if len(keyword) == 0 {
var total int