Skip to:
Content

BuddyPress.org

Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#6884 closed defect (bug) (fixed)

Improve validation in BP_XProfile_Field_Type->is_valid()

Reported by: dcavins's profile dcavins Owned by: dcavins's profile dcavins
Milestone: 2.5 Priority: low
Severity: minor Version: 2.4.0
Component: Extended Profile Keywords: has-patch has-unit-tests commit
Cc: dcavins

Description

When checking against a set of whitelisted values, the foreach in is_valid() doesn't break when it encounters an invalid value. Instead, it returns the validity of the last value in the array.

Attachments (2)

6884.01.patch (856 bytes) - added by dcavins 9 years ago.
Break if any of the values in the array are not whitelisted.
6884.02.patch (3.0 KB) - added by dcavins 9 years ago.
Break if any of the values in the array are not whitelisted. Adds unit test updates.

Download all attachments as: .zip

Change History (12)

@dcavins
9 years ago

Break if any of the values in the array are not whitelisted.

#1 @boonebgorges
9 years ago

  • Keywords needs-unit-tests added

#3 @dcavins
9 years ago

Ha ha, this is like groundhog day. Yes, there should be tests. :)

#4 @DJPaul
9 years ago

Specifically, the test needs to answer why the current tests for the XProfile Field Types do not catch this problem -- are those tests badly written? etc.

@dcavins
9 years ago

Break if any of the values in the array are not whitelisted. Adds unit test updates.

#5 @dcavins
9 years ago

  • Keywords has-unit-tests added; needs-unit-tests removed
  • Owner set to dcavins
  • Status changed from new to assigned
  • Version set to 2.4.0

#6 @DJPaul
9 years ago

@dcavins are you intending this for 2.5 or not? If so, you need to commit it on Monday.

#7 @DJPaul
9 years ago

  • Keywords commit added
  • Milestone changed from Awaiting Review to 2.5

If you attach a patch to a ticket, please move it to the active milestone, or it'll probably get overlooked. :)

#8 @dcavins
9 years ago

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

In 10592:

Profile: Improve validation in is_valid().

When checking a submitted array of values,
ensure that the foreach breaks when an
invalid value is encountered. Previously,
the foreach returned the validity of the
last element in the array.

Also update unit tests so that invalid values
appear in various positions in the array of
values to check.

Fixes #6884.

#9 @dcavins
9 years ago

Thanks @DJPaul . I wasn't thinking this was important enough to slip in after the first beta. But, it's also minor enough that slipping it in is no big deal. Thanks for the nudge.

This ticket was mentioned in Slack in #buddypress by dcavins. View the logs.


9 years ago

Note: See TracTickets for help on using tickets.