@@ -161,7 +161,7 @@ protected function get_image_reference( array $args ) {
161161 // If an image URL is provided, get the image from the URL.
162162 if ( ! empty ( $ args ['image_url ' ] ) ) {
163163 // Preserve data URIs as-is so the AI client can read the inline bytes.
164- if ( 0 === strpos ( $ args ['image_url ' ], 'data: ' ) ) {
164+ if ( str_starts_with ( $ args ['image_url ' ], 'data: ' ) ) {
165165 return $ this ->prepare_reference_result ( $ args ['image_url ' ] );
166166 }
167167
@@ -323,7 +323,7 @@ protected function maybe_map_url_to_local_path( string $url ): ?string {
323323 $ normalized_url = $ this ->normalize_upload_url ( $ url );
324324 $ normalized_baseurl = $ this ->normalize_upload_url ( $ uploads ['baseurl ' ] );
325325
326- if ( false === strpos ( $ normalized_url , $ normalized_baseurl ) ) {
326+ if ( ! str_contains ( $ normalized_url , $ normalized_baseurl ) ) {
327327 return null ;
328328 }
329329
@@ -339,8 +339,8 @@ protected function maybe_map_url_to_local_path( string $url ): ?string {
339339 // Reject path traversal attempts in the relative path.
340340 if (
341341 '.. ' === $ relative_path ||
342- 0 === strpos ( $ relative_path , '../ ' ) ||
343- false !== strpos ( $ relative_path , '/.. ' )
342+ str_starts_with ( $ relative_path , '../ ' ) ||
343+ str_contains ( $ relative_path , '/.. ' )
344344 ) {
345345 return null ;
346346 }
@@ -358,7 +358,7 @@ protected function maybe_map_url_to_local_path( string $url ): ?string {
358358 $ real_full_path = wp_normalize_path ( $ real_full_path );
359359
360360 // Ensure the resolved path is strictly within the uploads base directory.
361- if ( 0 !== strpos ( $ real_full_path , $ base_dir ) ) {
361+ if ( ! str_starts_with ( $ real_full_path , $ base_dir ) ) {
362362 return null ;
363363 }
364364
@@ -457,7 +457,7 @@ protected function sanitize_image_reference_input( $value ): string {
457457 return '' ;
458458 }
459459
460- if ( 0 === strpos ( $ value , 'data: ' ) ) {
460+ if ( str_starts_with ( $ value , 'data: ' ) ) {
461461 return $ value ;
462462 }
463463
0 commit comments