|
8 | 8 |
|
9 | 9 | "github.com/github/github-mcp-server/pkg/ifc" |
10 | 10 | "github.com/github/github-mcp-server/pkg/inventory" |
| 11 | + "github.com/github/github-mcp-server/pkg/sanitize" |
11 | 12 | "github.com/github/github-mcp-server/pkg/scopes" |
12 | 13 | "github.com/github/github-mcp-server/pkg/translations" |
13 | 14 | "github.com/github/github-mcp-server/pkg/utils" |
@@ -99,7 +100,7 @@ type WithCategoryNoOrder struct { |
99 | 100 | func fragmentToDiscussion(fragment NodeFragment) *github.Discussion { |
100 | 101 | return &github.Discussion{ |
101 | 102 | Number: github.Ptr(int(fragment.Number)), |
102 | | - Title: github.Ptr(string(fragment.Title)), |
| 103 | + Title: github.Ptr(sanitize.Sanitize(string(fragment.Title))), |
103 | 104 | HTMLURL: github.Ptr(string(fragment.URL)), |
104 | 105 | CreatedAt: &github.Timestamp{Time: fragment.CreatedAt.Time}, |
105 | 106 | UpdatedAt: &github.Timestamp{Time: fragment.UpdatedAt.Time}, |
@@ -360,8 +361,8 @@ func GetDiscussion(t translations.TranslationHelperFunc) inventory.ServerTool { |
360 | 361 | // like ListDiscussions and GetDiscussionComments). |
361 | 362 | response := map[string]any{ |
362 | 363 | "number": int(d.Number), |
363 | | - "title": string(d.Title), |
364 | | - "body": string(d.Body), |
| 364 | + "title": sanitize.Sanitize(string(d.Title)), |
| 365 | + "body": sanitize.Sanitize(string(d.Body)), |
365 | 366 | "url": string(d.URL), |
366 | 367 | "closed": bool(d.Closed), |
367 | 368 | "isAnswered": bool(d.IsAnswered), |
@@ -522,14 +523,14 @@ func GetDiscussionComments(t translations.TranslationHelperFunc) inventory.Serve |
522 | 523 | for _, c := range q.Repository.Discussion.Comments.Nodes { |
523 | 524 | comment := MinimalDiscussionComment{ |
524 | 525 | ID: fmt.Sprintf("%v", c.ID), |
525 | | - Body: string(c.Body), |
| 526 | + Body: sanitize.Sanitize(string(c.Body)), |
526 | 527 | IsAnswer: bool(c.IsAnswer), |
527 | 528 | ReplyTotalCount: c.Replies.TotalCount, |
528 | 529 | } |
529 | 530 | for _, r := range c.Replies.Nodes { |
530 | 531 | comment.Replies = append(comment.Replies, MinimalDiscussionComment{ |
531 | 532 | ID: fmt.Sprintf("%v", r.ID), |
532 | | - Body: string(r.Body), |
| 533 | + Body: sanitize.Sanitize(string(r.Body)), |
533 | 534 | IsAnswer: bool(r.IsAnswer), |
534 | 535 | }) |
535 | 536 | } |
@@ -564,7 +565,7 @@ func GetDiscussionComments(t translations.TranslationHelperFunc) inventory.Serve |
564 | 565 | for _, c := range q.Repository.Discussion.Comments.Nodes { |
565 | 566 | comments = append(comments, MinimalDiscussionComment{ |
566 | 567 | ID: fmt.Sprintf("%v", c.ID), |
567 | | - Body: string(c.Body), |
| 568 | + Body: sanitize.Sanitize(string(c.Body)), |
568 | 569 | IsAnswer: bool(c.IsAnswer), |
569 | 570 | }) |
570 | 571 | } |
|
0 commit comments