@ -4,7 +4,6 @@ import (
"code.gitea.io/gitea/modules/base"
"code.gitea.io/gitea/modules/context"
"code.gitea.io/gitea/routers/web/user"
"errors"
"fmt"
"net/http"
"regexp"
@ -41,15 +40,29 @@ func GetRenderedResourcesWithSearchLinks(ctx *context.Context, repo interface{},
return "" , err
}
resourceSubstitutionPattern := fmt . Sprintf ( ` - \[ \] $1 [найти](/explore/%s?tab=&q=$1) ` , strings . ToLower ( fieldName ) )
resourcesWithLinks := regExp . ReplaceAll ( [ ] byte ( resources ) , [ ] byte ( resourceSubstitutionPattern ) )
resourceNamesMatches := regExp . FindAllStringSubmatch ( resources , - 1 )
if resourceNamesMatches == nil {
return "" , err
}
var resourcesWithSafeURLs = strings . Clone ( resources )
var resourceName string
var searchQS string
for _ , matches := range resourceNamesMatches {
resourceName = matches [ 1 ]
searchQS = strings . ReplaceAll ( resourceName , " " , "+" )
resourceSubstitutionPattern := fmt . Sprintf (
` - \[ \] %s [найти](/explore/%s?tab=&q=%s) ` ,
resourceName ,
strings . ToLower ( fieldName ) ,
searchQS )
if resourcesWithLinks == nil {
return "" , errors . New ( "not found matches in resources" )
resourcesWithSafeURLs = strings . Replace ( resourcesWithSafeURLs , resourceName , resourceSubstitutionPattern , - 1 )
}
var renderedResourcesWithLinks string
renderedResourcesWithLinks , err = user . GetRenderedTextFieldByValue ( ctx , repo , string ( resourcesWithLinks ) )
var renderedResourcesWithSafeUR Ls string
renderedResourcesWithSafeUR Ls , err = user . GetRenderedTextFieldByValue ( ctx , repo , resourcesWithSafeUR Ls )
return renderedResourcesWithLinks , err
return renderedResourcesWithSafeUR Ls , err
}