Skip to content

Commit 460e1b1

Browse files
obenlandpfefferlegithub-actions[bot]
authored
Remove unused sanitize_url (#1462)
* Remove unused sanitize_url * Maybe fix changelog error? * Escape backticks * Escape it through json * Stringify to the rescue * # * Back to string * # * # * Add changelog * Whitespace --------- Co-authored-by: Matthias Pfefferle <[email protected]> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
1 parent 040e601 commit 460e1b1

File tree

3 files changed

+26
-18
lines changed

3 files changed

+26
-18
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Significance: patch
2+
Type: removed
3+
4+
Our version of `sanitize_url()` was unused—use Core's `sanitize_url()` instead.

.github/workflows/changelog.yml

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,17 +157,36 @@ jobs:
157157
- name: "Create changelog file from PR description"
158158
id: create-changelog-file
159159
if: steps.check-skip-label.outputs.skip-changelog != 'true' && steps.check-changelog-file.outputs.has-changelog-file != 'true' && steps.check-pr-body.outputs.has-changelog-info == 'true'
160+
env:
161+
PR_MESSAGE: '${{ steps.check-pr-body.outputs.message }}'
160162
uses: actions/github-script@v7
161163
with:
162164
script: |
163165
const { repo: { owner, repo }, payload : { pull_request : { number, head : { ref } } } } = context;
164166
165-
// Get the changelog information from the previous step
167+
// Get the changelog information from the previous step.
166168
const significance = '${{ steps.check-pr-body.outputs.significance }}';
167169
const type = '${{ steps.check-pr-body.outputs.type }}';
168-
const message = '${{ steps.check-pr-body.outputs.message }}';
169170
170-
// Create the changelog file content
171+
// Get the raw message from the previous step and process it.
172+
// We need to handle it as a regular string to avoid template literal syntax issues.
173+
// The message is passed through environment variables to avoid syntax issues.
174+
const rawMessage = process.env.PR_MESSAGE;
175+
176+
// Ensure the message is not empty.
177+
if ( ! rawMessage ) {
178+
core.setFailed( 'Changelog message is missing or empty. Please provide a meaningful message in the PR description.' );
179+
return;
180+
}
181+
182+
// Process the message to remove HTML comments and preserve special characters.
183+
let message = rawMessage
184+
// Remove HTML comments.
185+
.replace( /<!--[\s\S]*?-->/g, '' )
186+
// Trim whitespace.
187+
.trim();
188+
189+
// Create the changelog file content.
171190
const content = [
172191
`Significance: ${ significance }`,
173192
`Type: ${ type }`,

includes/functions.php

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -505,21 +505,6 @@ function is_blog_public() {
505505
return (bool) apply_filters( 'activitypub_is_blog_public', \get_option( 'blog_public', 1 ) );
506506
}
507507

508-
/**
509-
* Sanitize a URL.
510-
*
511-
* @param string $value The URL to sanitize.
512-
*
513-
* @return string|null The sanitized URL or null if invalid.
514-
*/
515-
function sanitize_url( $value ) {
516-
if ( filter_var( $value, FILTER_VALIDATE_URL ) === false ) {
517-
return null;
518-
}
519-
520-
return esc_url_raw( $value );
521-
}
522-
523508
/**
524509
* Extract recipient URLs from Activity object.
525510
*

0 commit comments

Comments
 (0)