@@ -24,7 +24,7 @@ function extract_from_phar( $path ) {
2424
2525 $ fname = basename ( $ path );
2626
27- $ tmp_path = get_temp_dir () . " wp-cli- $ fname " ;
27+ $ tmp_path = get_temp_dir () . uniqid ( ' wp-cli-extract-from-phar- ' , true ) . " - $ fname " ;
2828
2929 copy ( $ path , $ tmp_path );
3030
@@ -351,19 +351,21 @@ function pick_fields( $item, $fields ) {
351351 * @category Input
352352 *
353353 * @param string $content Some form of text to edit (e.g. post content)
354+ * @param string $title Title to display in the editor.
355+ * @param string $ext Extension to use with the temp file.
354356 * @return string|bool Edited text, if file is saved from editor; false, if no change to file.
355357 */
356- function launch_editor_for_input ( $ input , $ filename = 'WP-CLI ' ) {
358+ function launch_editor_for_input ( $ input , $ title = 'WP-CLI ' , $ ext = ' tmp ' ) {
357359
358360 check_proc_available ( 'launch_editor_for_input ' );
359361
360362 $ tmpdir = get_temp_dir ();
361363
362364 do {
363- $ tmpfile = basename ( $ filename );
365+ $ tmpfile = basename ( $ title );
364366 $ tmpfile = preg_replace ( '|\.[^.]*$| ' , '' , $ tmpfile );
365367 $ tmpfile .= '- ' . substr ( md5 ( mt_rand () ), 0 , 6 );
366- $ tmpfile = $ tmpdir . $ tmpfile . '.tmp ' ;
368+ $ tmpfile = $ tmpdir . $ tmpfile . '. ' . $ ext ;
367369 $ fp = fopen ( $ tmpfile , 'xb ' );
368370 if ( ! $ fp && is_writable ( $ tmpdir ) && file_exists ( $ tmpfile ) ) {
369371 $ tmpfile = '' ;
@@ -772,6 +774,31 @@ function trailingslashit( $string ) {
772774 return rtrim ( $ string , '/ \\' ) . '/ ' ;
773775}
774776
777+ /**
778+ * Normalize a filesystem path.
779+ *
780+ * On Windows systems, replaces backslashes with forward slashes
781+ * and forces upper-case drive letters.
782+ * Allows for two leading slashes for Windows network shares, but
783+ * ensures that all other duplicate slashes are reduced to a single one.
784+ * Ensures upper-case drive letters on Windows systems.
785+ *
786+ * @access public
787+ * @category System
788+ *
789+ * @param string $path Path to normalize.
790+ * @return string Normalized path.
791+ */
792+ function normalize_path ( $ path ) {
793+ $ path = str_replace ( '\\' , '/ ' , $ path );
794+ $ path = preg_replace ( '|(?<=.)/+| ' , '/ ' , $ path );
795+ if ( ': ' === substr ( $ path , 1 , 1 ) ) {
796+ $ path = ucfirst ( $ path );
797+ }
798+ return $ path ;
799+ }
800+
801+
775802/**
776803 * Convert Windows EOLs to *nix.
777804 *
@@ -1307,6 +1334,7 @@ function get_php_binary() {
13071334
13081335 // Available since PHP 5.4.
13091336 if ( defined ( 'PHP_BINARY ' ) ) {
1337+ // @codingStandardsIgnoreLine
13101338 return PHP_BINARY ;
13111339 }
13121340
0 commit comments