Escape get_permalink() in the 404 suggestion link - #2327
Open
thisismyurl wants to merge 1 commit into
Open
Conversation
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).
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 0 |
| Duplication | 0 |
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.
There was a problem hiding this comment.
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()withesc_url()for the 404 suggestion link’shref.
| <?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> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Small escaping fix. On the 404 template, the "internal suggestion" link echoed
get_permalink()straight into thehref. The title on that same line is alreadyesc_html()'d, so this just brings the URL up to match by wrapping it inesc_url(), which is also whatauthor.php,comments.php, andlibs/Assets.phpdo 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.)