| @@ -901,8 +901,10 @@ | ||
| 901 | 901 | $this->upload_avatar( $userid ); |
| 902 | 902 | } |
| 903 | 903 | |
| 904 | 904 | //Update Custom Fields |
| 905 | + // $custom_fields is still the raw $_POST['data']. The same values were merged into $user, where validate() has since dropped every field the current user may not edit and sanitize() has cleaned the rest, so read them back from $user: a key that is still there is one this user was allowed to submit, and its value is the sanitized one. | |
| 906 | + $custom_fields = array_intersect_key( $user, $custom_fields ); | |
| 905 | 907 | if( ! empty( $custom_fields ) && ( in_array( 'full', $type ) || in_array( 'custom_fields', $type ) ) ) { |
| 906 | 908 | $result_fields = $this->update_custom_fields( $userid, $custom_fields, false ); |
| 907 | 909 | } |
| 908 | 910 | |
| @@ -1666,16 +1668,17 @@ | ||
| 1666 | 1668 | } else { |
| 1667 | 1669 | $wheres[] = "`" . esc_sql( $field ) . "` LIKE '%" . esc_sql( $needle ) . "%'"; |
| 1668 | 1670 | } |
| 1669 | 1671 | } else { |
| 1670 | - $needle = preg_quote( preg_quote( $needle ) ); | |
| 1672 | + // Local var: $needle must stay raw for the remaining fields of this loop | |
| 1673 | + $n = wpforo_json_regexp_needle( $needle ); | |
| 1671 | 1674 | if( in_array( $f['type'], [ 'text', 'search', 'textarea' ], true ) ) { |
| 1672 | 1675 | $wheres[] = "`fields` REGEXP '[{,]\"" . $field . "\":(\\\[[^\\\[]*)?\"[^\"]*" . esc_sql( |
| 1673 | - $needle | |
| 1676 | + $n | |
| 1674 | 1677 | ) . "[^\"]*\"'"; |
| 1675 | 1678 | } else { |
| 1676 | 1679 | $wheres[] = "`fields` REGEXP '[{,]\"" . $field . "\":(\\\[[^\\\[]*)?\"" . esc_sql( |
| 1677 | - $needle | |
| 1680 | + $n | |
| 1678 | 1681 | ) . "\"'"; |
| 1679 | 1682 | } |
| 1680 | 1683 | } |
| 1681 | 1684 | } |
| @@ -1718,31 +1721,27 @@ | ||
| 1718 | 1721 | } |
| 1719 | 1722 | } else { |
| 1720 | 1723 | if( in_array( $f['type'], [ 'text', 'search', 'textarea' ], true ) ) { |
| 1721 | 1724 | if( is_scalar( $needle ) ) { |
| 1722 | - $needle = preg_quote( preg_quote( wpforo_encode( $needle ) ) ); | |
| 1723 | 1725 | $wheres[] = "`fields` REGEXP '[{,]\"" . $field . "\":(\\\[[^\\\[]*)?\"[^\"]*" . esc_sql( |
| 1724 | - $needle | |
| 1726 | + wpforo_json_regexp_needle( wpforo_encode( $needle ) ) | |
| 1725 | 1727 | ) . "[^\"]*\"'"; |
| 1726 | 1728 | } elseif( is_array( $needle ) ) { |
| 1727 | 1729 | foreach( $needle as $n ) { |
| 1728 | - $n = preg_quote( preg_quote( wpforo_encode( $n ) ) ); | |
| 1729 | 1730 | $wheres[] = "`fields` REGEXP '[{,]\"" . $field . "\":(\\\[[^\\\[]*)?\"[^\"]*" . esc_sql( |
| 1730 | - $n | |
| 1731 | + wpforo_json_regexp_needle( wpforo_encode( $n ) ) | |
| 1731 | 1732 | ) . "[^\"]*\"'"; |
| 1732 | 1733 | } |
| 1733 | 1734 | } |
| 1734 | 1735 | } else { |
| 1735 | 1736 | if( is_scalar( $needle ) ) { |
| 1736 | - $needle = preg_quote( preg_quote( wpforo_encode( $needle ) ) ); | |
| 1737 | 1737 | $wheres[] = "`fields` REGEXP '[{,]\"" . $field . "\":(\\\[[^\\\[]*)?\"" . esc_sql( |
| 1738 | - $needle | |
| 1738 | + wpforo_json_regexp_needle( wpforo_encode( $needle ) ) | |
| 1739 | 1739 | ) . "\"'"; |
| 1740 | 1740 | } elseif( is_array( $needle ) ) { |
| 1741 | 1741 | foreach( $needle as $n ) { |
| 1742 | - $n = preg_quote( preg_quote( wpforo_encode( $n ) ) ); | |
| 1743 | 1742 | $wheres[] = "`fields` REGEXP '[{,]\"" . $field . "\":(\\\[[^\\\[]*)?\"" . esc_sql( |
| 1744 | - $n | |
| 1743 | + wpforo_json_regexp_needle( wpforo_encode( $n ) ) | |
| 1745 | 1744 | ) . "\"'"; |
| 1746 | 1745 | } |
| 1747 | 1746 | } |
| 1748 | 1747 | } |