Skip to content

Check listing media URLs and treat more listing fields as text - #3181

Merged
tellyworth merged 6 commits into
trunkfrom
fix/company-video-url
Nov 13, 2026
Merged

tellyworth merged 6 commits into
trunkfrom
fix/company-video-url

Conversation

@tellyworth

@tellyworth tellyworth commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Changes Proposed in this Pull Request

Hardening for how listing fields are displayed, following on from 2.4.9 and 2.4.10.

  • Company video URL. The URL is listing data, whoever builds the player around it. It is now checked where it is saved (sanitize_meta_field_media_url()) and where it is read (get_the_company_video()), for every listing. A value that isn't a plain URL is treated as empty.
  • Markup built from listing data. protect_listing_media_output() keeps the company video player through the media pass. It now runs is_inert_media_markup() first and returns nothing if the markup fails, on every path and for every listing. This also covers markup returned by the the_company_video_embed filter.
  • Embeds. For listings whose author can't edit job listings, embeds come from WordPress's known providers only. The site no longer fetches the saved URL to discover one.
  • More fields shown as text. Salary, salary currency and X / Twitter username are displayed as the text that was entered on those listings, like company name, tagline and location.
  • Bracket encoding. wpjm_esc_listing_text() and restrict_content_html() now encode brackets as [ / ] through a shared encode_brackets(). WordPress turns the unpadded [ back into a bracket after it expands shortcodes, so that form did not stay encoded in content printed by a shortcode such as [job].
  • Descriptions stay restricted through later processing. Brackets inside HTML tags of a restricted description are percent-encoded. A character reference in an attribute is decoded again by the HTML filter the description passes through afterwards, on current WordPress.
  • Embeds in descriptions. For the same listings, an address in the description is only embedded when it belongs to one of WordPress's known providers, including embeds cached earlier, and the address of a media file is shown as a link.
  • How the checks are built. They use WordPress and PHP functions wherever one exists. The URL check is three conditions: esc_url_raw() doesn't change it a second time, html_entity_decode() doesn't change it, and it has no quote, angle bracket or space. The markup check reads attributes with WP_HTML_Tag_Processor. Brackets inside tags are found by splitting with wp_html_split() (the split WordPress itself uses for shortcodes) and letting PHP decode each character reference. One pattern for references that WordPress 6.4 and 6.5 leave undecoded is confined to has_reference_left_before_wp_66().
  • Tests. Two tests generate a few thousand inputs from a fixed seed and assert the rule each check exists for. Another reads the named references for brackets from PHP's own table. test_class.listing-description-processing.php checks the restricted description after the steps that follow the restriction. test_class.listing-field-sweep.php reads the fields from the submission form, fills each one, and renders the listing through every listing template. A field added later is covered without a new test. test_class.listing-media-url.php covers the URL and markup checks.
  • Docs. ADR 0001 records the rules and a "Keeping it true" section.

Behaviour changes to be aware of:

  • A company video on a guest, subscriber or employer listing that relied on embed discovery (a site that is not one of WordPress's known providers) no longer shows an embed. Direct video files and known providers such as YouTube and Vimeo are unchanged.
  • In a restricted description, a bracket inside a tag is written as %5B / %5D. Link addresses keep working; a bracket in a title or alt shows in that form.
  • A company video URL saved with an ampersand encoded more than once (&) shows no player.
  • get_the_company_video() returns an empty string for a value that isn't a plain URL.
  • the_job_salary() with $echo = false returns the brackets encoded for those listings.

Testing Instructions

  • vendor/bin/phpunit --filter 'Tests_Listing' runs the new and changed tests.
  • As a logged-out visitor or an employer, submit a listing with a company video that is a direct .mp4 URL, and another with a YouTube URL. Approve them. Both players show on the listing page, as before.
  • On the same kind of listing, enter [gallery] as the salary and as the X / Twitter username (enable salary under Job Listings → Settings → Job Listings). The listing page shows the text [gallery] in both places.
  • As an administrator, edit a listing you authored and check its company video still shows.

Release Notes

  • Fix: Check the company video URL before building the player.
  • Fix: Display the salary and X / Twitter fields as the text that was entered.
  • Fix: Look up embeds for restricted listings with known providers only.
  • Fix: Keep restricted listing descriptions as text through later processing.

New or Updated Hooks and Templates

  • the_company_video and the_company_video_embed: the filtered value is now checked before it is used. A URL that isn't a plain URL, or player markup whose media or URL attributes decode to markup, is not printed.

tellyworth and others added 6 commits November 13, 2026 14:08
The company video player is built from a URL saved with the listing. That
URL is now checked where it is saved and where it is read, for every
listing, and markup built from listing data is only printed when its media
and URL attributes hold plain values. Listings by authors who can't edit
job listings get embeds from WordPress's known providers only.

The salary, salary currency and X / Twitter username are displayed as the
text that was entered on those listings, like the company name, tagline
and location already are. Brackets are encoded in a form that stays
encoded when the content is processed again.

Adds a test that reads the submission form's fields and checks each one on
every template, so a field added later is covered.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Older versions of WordPress leave it encoded when an attribute is decoded.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Brackets inside HTML tags are percent-encoded: a character reference in an
attribute is decoded again by the HTML filter the description passes
through afterwards. Embeds in the description of a listing whose author
can't edit job listings come from WordPress's known providers only, as for
the company video, including embeds cached earlier.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
WordPress turns the address of a media file into a player shortcode. For
a listing whose author can't edit job listings it is now a link from the
start, on every path. The embed filters follow the listing whose content
is being processed, which isn't always the current post.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The media URL check is now three plain conditions: cleaning the URL again
doesn't change it, decoding it as HTML doesn't change it, and it has no
quote, angle bracket or space. The markup check reads attribute values
with WordPress's HTML parser and decodes them once more with PHP; the one
remaining pattern is confined to a helper for WordPress 6.4 and 6.5.
Brackets inside tags are found by letting PHP decode each character
reference, so no list of the ways to write a bracket is kept.

Adds tests generated from a fixed seed for the URL check and for
restricted descriptions, and a test that reads the named references for
brackets from PHP's own table.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@tellyworth
tellyworth merged commit 3b89571 into trunk Nov 13, 2026
8 checks passed
@tellyworth
tellyworth deleted the fix/company-video-url branch November 13, 2026 05:29
@tellyworth tellyworth added this to the 2.4.11 milestone Nov 13, 2026
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.

1 participant