Changeset 10429
- Timestamp:
- 11/05/2020 03:37:13 AM (5 years ago)
- Location:
- sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/readme
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/readme/class-parser.php
r10042 r10429 153 153 * Parser constructor. 154 154 * 155 * @param string $file_or_url 156 */ 157 public function __construct( $file_or_url ) { 158 if ( $file_or_url ) { 159 $this->parse_readme( $file_or_url ); 155 * @param string $string A Filepath, URL, or contents of a readme to parse. 156 */ 157 public function __construct( $string ) { 158 if ( file_exists( $string ) || preg_match( '!^https?://!i', $string ) ) { 159 $this->parse_readme( $string ); 160 } elseif ( $string ) { 161 $this->parse_readme_contents( $string ); 160 162 } 161 163 } … … 174 176 $contents = file_get_contents( $file_or_url, false, $context ); 175 177 178 return $this->parse_readme_contents( $contents ); 179 } 180 181 /** 182 * @param string $contents The contents of the readme to parse. 183 * @return bool 184 */ 185 protected function parse_readme_contents( $contents ) { 176 186 if ( preg_match( '!!u', $contents ) ) { 177 187 $contents = preg_split( '!\R!u', $contents ); -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/readme/class-validator.php
r10277 r10429 64 64 public function validate_content( $readme ) { 65 65 66 // Security note: Keep the data: protocol here, Parser accepts a string HOWEVER 67 // if a submitted readme.txt URL contents were to contain a file or URL-like string, 68 // it could bypass the protections above in validate_url(). 66 69 $readme = new Parser( 'data:text/plain,' . urlencode( $readme ) ); 67 70
Note: See TracChangeset
for help on using the changeset viewer.