| @@ -14,9 +14,9 @@ | ||
| 14 | 14 | |
| 15 | 15 | /** |
| 16 | 16 | * Return an array of available converters |
| 17 | 17 | * |
| 18 | - * @since 2.6.0 bbPress (r6447) | |
| 18 | + * @since 2.6.0 bbPress (r6448) | |
| 19 | 19 | * |
| 20 | 20 | * @return array |
| 21 | 21 | */ |
| 22 | 22 | function bbp_get_converters() { |
| @@ -54,13 +54,25 @@ | ||
| 54 | 54 | return (array) apply_filters( 'bbp_get_converters', $files ); |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | /** |
| 58 | + * Check a source database table prefix before using it in converter queries. | |
| 59 | + * | |
| 60 | + * @since 2.6.19 bbPress (r7737) | |
| 61 | + * | |
| 62 | + * @param mixed $prefix Source database table prefix. | |
| 63 | + * @return bool Whether the prefix contains only valid table-prefix characters. | |
| 64 | + */ | |
| 65 | +function bbp_is_valid_converter_prefix( $prefix ) { | |
| 66 | + return is_string( $prefix ) && ( 0 === preg_match( '|[^a-z0-9_]|i', $prefix ) ); | |
| 67 | +} | |
| 68 | + | |
| 69 | +/** | |
| 58 | 70 | * This is a function that is purposely written to look like a "new" statement. |
| 59 | 71 | * It is basically a dynamic loader that will load in the platform conversion |
| 60 | 72 | * of your choice. |
| 61 | 73 | * |
| 62 | - * @since 2.0.0 | |
| 74 | + * @since 2.1.0 bbPress (r3816) | |
| 63 | 75 | * |
| 64 | 76 | * @param string $platform Name of valid platform class. |
| 65 | 77 | * |
| 66 | 78 | * @return mixed Object if converter exists, null if not |
| @@ -71,8 +83,13 @@ | ||
| 71 | 83 | $converter = null; |
| 72 | 84 | |
| 73 | 85 | // Bail if no platform |
| 74 | 86 | if ( empty( $platform ) ) { |
| 87 | + return $converter; | |
| 88 | + } | |
| 89 | + | |
| 90 | + // Never build source-table queries with an invalid saved prefix. | |
| 91 | + if ( ! bbp_is_valid_converter_prefix( get_option( '_bbp_converter_db_prefix', '' ) ) ) { | |
| 75 | 92 | return $converter; |
| 76 | 93 | } |
| 77 | 94 | |
| 78 | 95 | // Get the available converters |