Skip to content

Clean up refreshViewedFilesSummary#36868

Merged
silverwind merged 6 commits intogo-gitea:mainfrom
silverwind:fix-170
Mar 8, 2026
Merged

Clean up refreshViewedFilesSummary#36868
silverwind merged 6 commits intogo-gitea:mainfrom
silverwind:fix-170

Conversation

@silverwind
Copy link
Copy Markdown
Member

@silverwind silverwind commented Mar 8, 2026

  1. Use textContent instead of innerHTML to fix https://github.com/go-gitea/gitea/security/code-scanning/170.
  2. Clean up surrounding code to remove unnecessary if checks on elements that are guaranteed to exist.

Use `textContent` instead of `innerHTML` to set the viewed files
summary label. The template is plain text with number placeholders,
so `innerHTML` is unnecessary and triggers a CodeQL XSS alert.

Co-Authored-By: Claude (Opus 4.6) <noreply@anthropic.com>
@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Mar 8, 2026
Co-Authored-By: Claude (Opus 4.6) <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the pull request “viewed files” summary label rendering to avoid unsafe HTML insertion and satisfy the CodeQL finding linked in the PR description.

Changes:

  • Replace innerHTML usage with textContent when updating #viewed-files-summary-label.
  • Keep the existing placeholder substitution logic for viewed/total file counts.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

silverwind and others added 2 commits March 8, 2026 19:02
Co-Authored-By: Claude (Opus 4.6) <noreply@anthropic.com>
These elements are always present when the function is called because
the checkboxes and summary elements share the same template condition.

Co-Authored-By: Claude (Opus 4.6) <noreply@anthropic.com>
@silverwind silverwind changed the title Fix CodeQL issue in pull-view-file.ts Clean up refreshViewedFilesSummary Mar 8, 2026
Co-Authored-By: Claude (Opus 4.6) <noreply@anthropic.com>
@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Mar 8, 2026
@silverwind silverwind added the skip-changelog This PR is irrelevant for the (next) changelog, for example bug fixes for unreleased features. label Mar 8, 2026
@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Mar 8, 2026
@silverwind silverwind enabled auto-merge (squash) March 8, 2026 20:48
@silverwind silverwind merged commit a52617b into go-gitea:main Mar 8, 2026
26 checks passed
@silverwind silverwind deleted the fix-170 branch March 8, 2026 20:49
@GiteaBot GiteaBot added this to the 1.26.0 milestone Mar 8, 2026
silverwind added a commit to silverwind/gitea that referenced this pull request Mar 8, 2026
* main: (26 commits)
  Clean up `refreshViewedFilesSummary` (go-gitea#36868)
  Remove `util.URLJoin` and replace all callers with direct path concatenation (go-gitea#36867)
  Optimize Docker build with dependency layer caching (go-gitea#36864)
  Fix URLJoin, markup render link reoslving, sign-in/up/linkaccount page common data (go-gitea#36861)
  Fix CodeQL code scanning alerts (go-gitea#36858)
  Refactor auth middleware (go-gitea#36848)
  Update Nix flake (go-gitea#36857)
  Update JS deps (go-gitea#36850)
  Load `mentionValues` asynchronously (go-gitea#36739)
  [skip ci] Updated translations via Crowdin
  Fix dbfs error handling (go-gitea#36844)
  Fix OAuth2 authorization code expiry and reuse handling (go-gitea#36797)
  Fix org permission API visibility checks for hidden members and private orgs (go-gitea#36798)
  Fix non-admins unable to automerge PRs from forks (go-gitea#36833)
  upgrade to github.com/cloudflare/circl 1.6.3, svgo 4.0.1, markdownlint-cli 0.48.0 (go-gitea#36837)
  Fix dump release asset bug (go-gitea#36799)
  build(deps): update material-icon-theme v5.32.0 (go-gitea#36832)
  Fix bug to check whether user can update pull request branch or rebase branch (go-gitea#36465)
  Fix forwarded proto handling for public URL detection (go-gitea#36810)
  Fix artifacts v4 backend upload problems (go-gitea#36805)
  ...

# Conflicts:
#	pnpm-lock.yaml
zjjhot added a commit to zjjhot/gitea that referenced this pull request Mar 10, 2026
* giteaofficial/main:
  Update minimum go version to 1.26.1, golangci-lint to 2.11.2, fix test style (go-gitea#36876)
  Add render cache for SVG icons (go-gitea#36863)
  Fix incorrect viewed files counter if reverted change was viewed (go-gitea#36819)
  [skip ci] Updated translations via Crowdin
  Clean up `refreshViewedFilesSummary` (go-gitea#36868)
  Remove `util.URLJoin` and replace all callers with direct path concatenation (go-gitea#36867)
  Optimize Docker build with dependency layer caching (go-gitea#36864)
  Fix URLJoin, markup render link reoslving, sign-in/up/linkaccount page common data (go-gitea#36861)
  Fix CodeQL code scanning alerts (go-gitea#36858)
  Refactor auth middleware (go-gitea#36848)
  Update Nix flake (go-gitea#36857)
  Update JS deps (go-gitea#36850)
  Load `mentionValues` asynchronously (go-gitea#36739)
  [skip ci] Updated translations via Crowdin
  Fix dbfs error handling (go-gitea#36844)
  Fix OAuth2 authorization code expiry and reuse handling (go-gitea#36797)
  Fix org permission API visibility checks for hidden members and private orgs (go-gitea#36798)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. modifies/frontend skip-changelog This PR is irrelevant for the (next) changelog, for example bug fixes for unreleased features.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants