Skip to content

Escape get_permalink() in the 404 suggestion link - #2327

Open
thisismyurl wants to merge 1 commit into
chrisblakley:mainfrom
thisismyurl:fix/escape-404-suggestion-permalink
Open

Escape get_permalink() in the 404 suggestion link#2327
thisismyurl wants to merge 1 commit into
chrisblakley:mainfrom
thisismyurl:fix/escape-404-suggestion-permalink

Conversation

@thisismyurl

Copy link
Copy Markdown

Small escaping fix. On the 404 template, the "internal suggestion" link echoed get_permalink() straight into the href. The title on that same line is already esc_html()'d, so this just brings the URL up to match by wrapping it in esc_url(), which is also what author.php, comments.php, and libs/Assets.php do for their URLs.

One line, and esc_url() returns the same URL for a normal permalink, so nothing changes except the hardening.

Nebula's a genuinely thorough framework to read through, by the way. Nice to send a small thing its way.

(full disclosure: AI helped me spot this and check it against the rest of the theme; the change and this note are mine.)

The suggested-page link on the 404 template echoed get_permalink()
straight into the href. Wrap it with esc_url() to match the escaping
already used on the title on the same line, and on URLs elsewhere in
the theme (author.php, comments.php, libs/Assets.php).
Copilot AI review requested due to automatic review settings July 14, 2026 13:12
@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 0 complexity · 0 duplication

Metric Results
Complexity 0
Duplication 0

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Hardens the 404 “internal suggestion” link output by properly escaping the permalink before echoing it into the href attribute, aligning it with existing URL-escaping practices elsewhere in the theme.

Changes:

  • Wrap get_permalink() with esc_url() for the 404 suggestion link’s href.

Comment thread 404.php
<?php endif; ?>

<a class="internal-suggestion" href="<?php echo get_permalink(); ?>"><?php echo esc_html(get_the_title()); ?></a>
<a class="internal-suggestion" href="<?php echo esc_url( get_permalink() ); ?>"><?php echo esc_html(get_the_title()); ?></a>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants