Photo Directory: make EXIF value handling consistent and escape metadata output - #853
Photo Directory: make EXIF value handling consistent and escape metadata output#853obenland wants to merge 2 commits into
Conversation
…ata output The `iso` case in `Photo::get_exif()` passed its value through as-is, while `aperture`, `focal_length` and `shutter_speed` each cast or reformat theirs. Cast it to an integer to match, and skip non-positive values the way `focal_length` already does. Escape metadata at the point of output as well: EXIF label/value pairs, colour, category and tag names, the stored original filename, the contributor display names in the moderator link and flag notice, and the flagged-photos count link. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
There was a problem hiding this comment.
Pull request overview
This PR hardens the Photo Directory plugin’s metadata rendering by consistently escaping user/content-derived values at output time, and it makes Photo::get_exif() treat iso like the other camera settings by normalizing it to a positive integer.
Changes:
- Normalize EXIF
isoto an integer and skip non-positive values for consistency with other EXIF fields. - Escape metadata output at render time across EXIF output, taxonomy term names, moderator display names/profile links, pending-submission rows, and flagged-photo links.
- Replace
sanitize_text_field()(sanitization) withesc_html()(output escaping) where values are being rendered.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
wordpress.org/public_html/wp-content/plugins/photo-directory/inc/template-tags.php |
Escapes term names (colors/categories/tags) and EXIF labels/values when rendering. |
wordpress.org/public_html/wp-content/plugins/photo-directory/inc/photo.php |
Normalizes EXIF ISO to positive int; escapes moderator display name in rendered moderator link. |
wordpress.org/public_html/wp-content/plugins/photo-directory/inc/moderation.php |
Escapes original filename and submission date when rendering pending submissions table rows. |
wordpress.org/public_html/wp-content/plugins/photo-directory/inc/flagged.php |
Escapes the flagged-photos count link URL before output. |
wordpress.org/public_html/wp-content/plugins/photo-directory/inc/admin.php |
Escapes profile URL and display name in the flagged/unflagged admin notice. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Photo::get_exif()normalises the camera settings it returns, but theisocase only sets a label and passes its value straight through, whileaperture,focal_lengthandshutter_speedeach cast or reformat theirs. This castsisoto an integer for consistency and skips non-positive values the same wayfocal_lengthdoes.While in there, metadata is now escaped where it is rendered rather than assumed safe from its storage path:
show_exif()— label and valueshow_colors()/show_categories()/show_tags()— term namesPhoto::get_moderator_link()and the flag/unflag admin notice —esc_html()for the display name instead ofsanitize_text_field(), which is a sanitiser rather than an escaper, plusesc_url()on the adjacent profile linkesc_url()No behaviour change beyond ISO now rendering as a plain integer.
Companion change in the theme: WordPress/wporg-photo-directory (meta-list block renders these same values).