PluginProbe
Sharing Image / 3.7
Sharing Image v3.7
3.10 trunk 2.0 2.0.0 2.0.1 2.0.10 2.0.11 2.0.12 2.0.13 2.0.14 2.0.15 2.0.16 2.0.17 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.0.8 2.0.9 3.0 3.1 3.2 3.3 All 29 releases
← All changes | classes/class-config.php +2 -47 trunk3.7 View file →
@@ -339,13 +339,9 @@
339 339 $sanitized['autogenerate'] = sanitize_key( $config['autogenerate'] );
340 340 }
341 341
342 342 if ( isset( $config['storage'] ) ) {
343 - $storage = self::sanitize_storage_path( $config['storage'] );
344 -
345 - if ( ! empty( $storage ) ) {
346 - $sanitized['storage'] = $storage;
347 - }
343 + $sanitized['storage'] = sanitize_text_field( $config['storage'] );
348 344 }
349 345
350 346 if ( isset( $config['suspend'] ) ) {
351 347 $sanitized['suspend'] = 'suspend';
@@ -393,16 +389,10 @@
393 389 *
394 390 * @return array Path and url to upload directory.
395 391 */
396 392 private static function create_upload_dir( $storage ) {
397 - $storage = self::sanitize_storage_path( $storage );
393 + $storage = trim( $storage, '/' );
398 394
399 - if ( empty( $storage ) ) {
400 - $directory = wp_upload_dir();
401 -
402 - return array( $directory['path'], $directory['url'] );
403 - }
404 -
405 395 /**
406 396 * Change permissions when creating new folders.
407 397 *
408 398 * @param int $permissions New directory access permissions. By default 0755.
@@ -412,41 +402,6 @@
412 402 // We do not pay attention to the possible error.
413 403 wp_mkdir_p( ABSPATH . $storage, $permissions, true );
414 404
415 405 return array( ABSPATH . $storage, site_url( $storage ) );
416 - }
417 -
418 - /**
419 - * Sanitize custom storage path.
420 - *
421 - * @param string $storage Relative directory path from WordPress root.
422 - *
423 - * @return string Sanitized path, or empty string when invalid.
424 - */
425 - private static function sanitize_storage_path( $storage ) {
426 - if ( ! is_scalar( $storage ) ) {
427 - return '';
428 - }
429 -
430 - $storage = sanitize_text_field( $storage );
431 - $storage = wp_normalize_path( $storage );
432 - $storage = trim( $storage, '/' );
433 -
434 - if ( '' === $storage || '.' === $storage ) {
435 - return '';
436 - }
437 -
438 - if ( false !== strpos( $storage, '://' ) || false !== strpos( $storage, ':' ) ) {
439 - return '';
440 - }
441 -
442 - $parts = explode( '/', $storage );
443 -
444 - foreach ( $parts as $part ) {
445 - if ( '' === $part || '.' === $part || '..' === $part ) {
446 - return '';
447 - }
448 - }
449 -
450 - return implode( '/', $parts );
451 406 }
452 407 }