Fix sanitize_ids to reject negative values and fix translation files#118
Merged
Fix sanitize_ids to reject negative values and fix translation files#118
Conversation
Co-authored-by: erseco <1876752+erseco@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add support for attachments in document CPT
Add attachments metabox to document CPT
Mar 4, 2026
Comment on lines
+109
to
+153
| public function save( $post_id, $post = null, $update = false ) { | ||
| unset( $update ); | ||
|
|
||
| if ( ! isset( $_POST[ self::NONCE_NAME ] ) ) { | ||
| return; | ||
| } | ||
|
|
||
| $nonce = sanitize_text_field( wp_unslash( $_POST[ self::NONCE_NAME ] ) ); | ||
| if ( ! wp_verify_nonce( $nonce, self::NONCE_ACTION ) ) { | ||
| return; | ||
| } | ||
|
|
||
| if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) { | ||
| return; | ||
| } | ||
|
|
||
| if ( wp_is_post_autosave( $post_id ) || wp_is_post_revision( $post_id ) ) { | ||
| return; | ||
| } | ||
|
|
||
| if ( ! current_user_can( 'edit_post', $post_id ) ) { | ||
| return; | ||
| } | ||
|
|
||
| if ( null === $post ) { | ||
| $post = get_post( $post_id ); | ||
| } | ||
|
|
||
| if ( ! $post instanceof WP_Post ) { | ||
| return; | ||
| } | ||
|
|
||
| $raw = isset( $_POST['documentate_attachments'] ) | ||
| ? sanitize_text_field( wp_unslash( $_POST['documentate_attachments'] ) ) | ||
| : ''; | ||
|
|
||
| $ids = self::sanitize_ids( $raw ); | ||
|
|
||
| if ( empty( $ids ) ) { | ||
| delete_post_meta( $post_id, self::META_KEY ); | ||
| return; | ||
| } | ||
|
|
||
| update_post_meta( $post_id, self::META_KEY, $ids ); | ||
| } |
Check warning
Code scanning / PHPMD
Code Size Rules: NPathComplexity Warning
Co-authored-by: erseco <1876752+erseco@users.noreply.github.com>
Copilot
AI
changed the title
Add attachments metabox to document CPT
Fix sanitize_ids to reject negative values before absint conversion
Mar 4, 2026
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Collaborator
|
@copilot can you fix this msgid "Add to document" |
Co-authored-by: erseco <1876752+erseco@users.noreply.github.com>
Contributor
Author
Fixed in |
Copilot
AI
changed the title
Fix sanitize_ids to reject negative values before absint conversion
Fix sanitize_ids to reject negative values and fix translation files
Mar 4, 2026
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.
absint('-1')returns1(absolute value), so negative input strings were incorrectly accepted as valid attachment IDs insanitize_ids().includes/document/meta/class-document-attachments-meta-box.php: Validate withis_numeric()and(int) $trimmed <= 0before callingabsint(), filtering out zero, negative, and non-numeric values.languages/documentate-es_ES.po: Fixed missing blank line separator between "Add to document" and "(mandatory field)" entries that caused PO parsers to show an emptymsgstrfor "Add to document". Also removed a duplicate "Remove" entry and consolidated its source references.languages/documentate.pot: Added missing attachment-related strings (Attachments, Add files, Select files, Add to document) with source references.languages/documentate-es_ES.mo: Regenerated binary translation file.Original prompt
documentCPT for supporting files #116✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.