Make WordPress Core

Opened 9 years ago

Closed 7 years ago

#36170 closed enhancement (fixed)

Small refactor in the validate_file method + unit tests

Reported by: borgesbruno's profile borgesbruno Owned by: johnbillion's profile johnbillion
Milestone: 4.9 Priority: normal
Severity: normal Version:
Component: Filesystem API Keywords: has-patch has-unit-tests
Focuses: Cc:

Description

The validate_file( $file, $allowed_files = '' ) method has as third param an array of allowed files, but the default value is a string, I created this patch using as default value an empty array instead of a empty string.

Beyond that, I wrote some unit tests for this change and to improve de code coverage.

Attachments (4)

36170.diff (1.4 KB) - added by borgesbruno 9 years ago.
Patch 36170
36170.2.diff (1.5 KB) - added by borgesbruno 9 years ago.
Using type hint and changing the provider
36170.3.diff (1.5 KB) - added by borgesbruno 9 years ago.
Removing type hint
36170.4.diff (1.0 KB) - added by borgesbruno 8 years ago.

Download all attachments as: .zip

Change History (13)

@borgesbruno
9 years ago

Patch 36170

#1 @borgesbruno
9 years ago

  • Keywords has-patch has-unit-tests added

@borgesbruno
9 years ago

Using type hint and changing the provider

@borgesbruno
9 years ago

Removing type hint

#2 @borgesbruno
9 years ago

I've removed the type hint, because is also necessary to do the refactor for
validate_file_to_edit method.

Last edited 9 years ago by borgesbruno (previous) (diff)

#3 @borgesbruno
9 years ago

  • Keywords dev-feedback added

#4 @borgesbruno
9 years ago

Please review

#5 @ocean90
8 years ago

  • Component changed from General to Filesystem API
  • Keywords needs-refresh added; dev-feedback removed

@borgesbruno Thanks for your patch and the unit tests.

Can you please adjust your patch according our coding standards?

Let's change the default value for validate_file_to_edit() too.

@borgesbruno
8 years ago

#6 @borgesbruno
8 years ago

  • Keywords dev-feedback added; needs-refresh removed

Tks for your feedback @ocean90, to avoid theses small errors with codings standards, now I'm using the phpcs with WordPress standard mode.
I've fixed theses errors on the last patch, please, if you can review again =)

#7 @johnbillion
7 years ago

In 42007:

Docs: Improve the docs for validate_file() and validate_file_to_edit().

See #42016, #36170, #41017

#8 @johnbillion
7 years ago

  • Keywords dev-feedback removed
  • Milestone changed from Awaiting Review to 4.9
  • Owner set to johnbillion
  • Status changed from new to reviewing

#9 @johnbillion
7 years ago

  • Resolution set to fixed
  • Status changed from reviewing to closed

In 42011:

Filesystem API: Add more specificity to the rules for valid files in validate_file().

This now treats files containing ./ as valid, and also treats files containing a trailing ../ as valid due to widespread use of this pattern in theme and plugin zip files.

Adds tests.

Props Ipstenu, borgesbruno, DavidAnderson, philipjohn, birgire
Fixes #42016, #36170

Note: See TracTickets for help on using tickets.