You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@answer.apache.org by li...@apache.org on 2024/04/26 02:26:55 UTC

(incubator-answer) 01/10: fix: Unescape when displaying site name

This is an automated email from the ASF dual-hosted git repository.

linkinstar pushed a commit to branch test
in repository https://gitbox.apache.org/repos/asf/incubator-answer.git

commit 0dce38483950ac5e3feaf1f42b2190ddef5d5400
Author: sy-records <52...@qq52o.cn>
AuthorDate: Fri Apr 19 10:26:03 2024 +0800

    fix: Unescape when displaying site name
---
 internal/controller_admin/siteinfo_controller.go     | 2 ++
 internal/service/siteinfo_common/siteinfo_service.go | 2 ++
 2 files changed, 4 insertions(+)

diff --git a/internal/controller_admin/siteinfo_controller.go b/internal/controller_admin/siteinfo_controller.go
index 6c1966b3..1526fd20 100644
--- a/internal/controller_admin/siteinfo_controller.go
+++ b/internal/controller_admin/siteinfo_controller.go
@@ -21,6 +21,7 @@ package controller_admin
 
 import (
 	"net/http"
+	"html"
 
 	"github.com/apache/incubator-answer/internal/base/handler"
 	"github.com/apache/incubator-answer/internal/base/middleware"
@@ -237,6 +238,7 @@ func (sc *SiteInfoController) UpdateGeneral(ctx *gin.Context) {
 		return
 	}
 	err := sc.siteInfoService.SaveSiteGeneral(ctx, req)
+	req.Name = html.UnescapeString(req.Name)
 	handler.HandleResponse(ctx, err, req)
 }
 
diff --git a/internal/service/siteinfo_common/siteinfo_service.go b/internal/service/siteinfo_common/siteinfo_service.go
index 2036ec6e..01585876 100644
--- a/internal/service/siteinfo_common/siteinfo_service.go
+++ b/internal/service/siteinfo_common/siteinfo_service.go
@@ -22,6 +22,7 @@ package siteinfo_common
 import (
 	"context"
 	"encoding/json"
+	"html"
 
 	"github.com/apache/incubator-answer/internal/base/constant"
 	"github.com/apache/incubator-answer/internal/entity"
@@ -70,6 +71,7 @@ func (s *siteInfoCommonService) GetSiteGeneral(ctx context.Context) (resp *schem
 	if err = s.GetSiteInfoByType(ctx, constant.SiteTypeGeneral, resp); err != nil {
 		return nil, err
 	}
+	resp.Name = html.UnescapeString(resp.Name)
 	return resp, nil
 }