Changeset 7921

Show
Ignore:
Timestamp:
05/12/08 23:51:54 (4 months ago)
Author:
ryan
Message:

Add some page template validation

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/wp-admin/includes/file.php

    r7895 r7921  
    6767    touch($filename); 
    6868    return $filename; 
    69 } 
    70  
    71 function validate_file( $file, $allowed_files = '' ) { 
    72     if ( false !== strpos( $file, '..' )) 
    73         return 1; 
    74  
    75     if ( false !== strpos( $file, './' )) 
    76         return 1; 
    77  
    78     if (':' == substr( $file, 1, 1 )) 
    79         return 2; 
    80  
    81     if (!empty ( $allowed_files ) && (!in_array( $file, $allowed_files ) ) ) 
    82         return 3; 
    83  
    84     return 0; 
    8569} 
    8670 
  • trunk/wp-includes/functions.php

    r7884 r7921  
    17501750} 
    17511751 
     1752function validate_file( $file, $allowed_files = '' ) { 
     1753    if ( false !== strpos( $file, '..' )) 
     1754        return 1; 
     1755 
     1756    if ( false !== strpos( $file, './' )) 
     1757        return 1; 
     1758 
     1759    if (':' == substr( $file, 1, 1 )) 
     1760        return 2; 
     1761 
     1762    if (!empty ( $allowed_files ) && (!in_array( $file, $allowed_files ) ) ) 
     1763        return 3; 
     1764 
     1765    return 0; 
     1766} 
     1767 
    17521768?> 
  • trunk/wp-includes/theme.php

    r7586 r7921  
    420420        $template = ''; 
    421421 
    422     if ( !empty($template) && file_exists(TEMPLATEPATH . "/$template") ) 
     422    if ( !empty($template) && !validate_file($template) && file_exists(TEMPLATEPATH . "/$template") ) 
    423423        $template = TEMPLATEPATH . "/$template"; 
    424424    elseif ( file_exists(TEMPLATEPATH . "/page.php") )