Ticket #9716: 9716.patch
File 9716.patch, 4.2 KB (added by , 13 years ago) |
---|
-
wp-admin/theme-editor.php
83 83 84 84 $newcontent = stripslashes($_POST['newcontent']); 85 85 $theme = urlencode($theme); 86 87 $neweol = (isset($_POST['neweol']) ? $_POST['neweol'] : ''); 88 $pattern = "/ 89 ([^\r\n]|^) # non-whitespace char, backreference 1 90 (?: 91 [\r](?![\n]) | # +CR -LF 92 (?<![\r])[\n] | # -CR +LF 93 [\n][\r] | # +LF +CR 94 [\r][\n] # +CR +LF 95 ) 96 /xm"; 97 switch ($neweol) { 98 case 'windows' : 99 $newcontent = preg_replace($pattern, "$1\r\n", $newcontent); 100 break; 101 case 'unix' : 102 $newcontent = preg_replace($pattern, "$1\n", $newcontent); 103 break; 104 } 105 86 106 if (is_writeable($file)) { 87 107 //is_writable() not always reliable, check return value. see comments @ http://uk.php.net/is_writable 88 $f = fopen($file, 'w+ ');108 $f = fopen($file, 'w+b'); 89 109 if ($f !== FALSE) { 90 110 fwrite($f, $newcontent); 91 111 fclose($f); … … 231 251 <input type="hidden" name="file" value="<?php echo esc_attr($file) ?>" /> 232 252 <input type="hidden" name="theme" value="<?php echo esc_attr($theme) ?>" /> 233 253 <input type="hidden" name="scrollto" id="scrollto" value="<?php echo $scrollto; ?>" /> 254 <div id="line-endings"> 255 <label for="neweol"><?php _e('Line endings:'); ?></label> 256 <select name="neweol" id="neweol"> 257 <?php $windows_eol = (false !== strpos($content, "\r\n")); ?> 258 <option <?php if ($windows_eol) : ?>selected="selected"<?php endif; ?>value="windows">Windows</option> 259 <option <?php if (!$windows_eol) : ?>selected="selected"<?php endif; ?>value="unix">Unix / Linux / Mac OS X</option> 260 </select> 261 </div> 234 262 </div> 235 263 <?php if ( isset($functions ) && count($functions) ) { ?> 236 264 <div id="documentation" class="hide-if-no-js"> -
wp-admin/plugin-editor.php
53 53 check_admin_referer('edit-plugin_' . $file); 54 54 55 55 $newcontent = stripslashes($_POST['newcontent']); 56 57 $neweol = (isset($_POST['neweol']) ? $_POST['neweol'] : ''); 58 $pattern = "/ 59 ([^\r\n]|^) # non-whitespace char, backreference 1 60 (?: 61 [\r](?![\n]) | # +CR -LF 62 (?<![\r])[\n] | # -CR +LF 63 [\n][\r] | # +LF +CR 64 [\r][\n] # +CR +LF 65 ) 66 /xm"; 67 switch ($neweol) { 68 case 'windows' : 69 $newcontent = preg_replace($pattern, "$1\r\n", $newcontent); 70 break; 71 case 'unix' : 72 $newcontent = preg_replace($pattern, "$1\n", $newcontent); 73 break; 74 } 75 56 76 if ( is_writeable($real_file) ) { 57 $f = fopen($real_file, 'w+ ');77 $f = fopen($real_file, 'w+b'); 58 78 fwrite($f, $newcontent); 59 79 fclose($f); 60 80 … … 230 250 <input type="hidden" name="file" value="<?php echo esc_attr($file) ?>" /> 231 251 <input type="hidden" name="plugin" value="<?php echo esc_attr($plugin) ?>" /> 232 252 <input type="hidden" name="scrollto" id="scrollto" value="<?php echo $scrollto; ?>" /> 253 <div id="line-endings"> 254 <label for="neweol"><?php _e('Line endings:'); ?></label> 255 <select name="neweol" id="neweol"> 256 <?php $windows_eol = (false !== strpos($content, "\r\n")); ?> 257 <option <?php if ($windows_eol) : ?>selected="selected"<?php endif; ?>value="windows">Windows</option> 258 <option <?php if (!$windows_eol) : ?>selected="selected"<?php endif; ?>value="unix">Unix / Linux / Mac OS X</option> 259 </select> 260 </div> 233 261 </div> 234 262 <?php if ( !empty( $docs_select ) ) : ?> 235 263 <div id="documentation" class="hide-if-no-js"><label for="docs-list"><?php _e('Documentation:') ?></label> <?php echo $docs_select ?> <input type="button" class="button" value="<?php esc_attr_e( 'Lookup' ) ?> " onclick="if ( '' != jQuery('#docs-list').val() ) { window.open( 'http://api.wordpress.org/core/handbook/1.0/?function=' + escape( jQuery( '#docs-list' ).val() ) + '&locale=<?php echo urlencode( get_locale() ) ?>&version=<?php echo urlencode( $wp_version ) ?>&redirect=true'); }" /></div>