Changeset 949454
- Timestamp:
- 07/16/2014 08:13:53 AM (12 years ago)
- Location:
- scalable-vector-graphics-svg/trunk
- Files:
-
- 3 added
- 2 edited
-
library (added)
-
library/class.svg-sanitizer.php (added)
-
library/data.svg-whitelist.php (added)
-
readme.txt (modified) (3 diffs)
-
scalable-vector-graphics.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
scalable-vector-graphics-svg/trunk/readme.txt
r909301 r949454 4 4 Tags: svg, scalable, vector, graphics, mime, type, images, uploads 5 5 Requires at least: 3.0 6 Tested up to: 3.96 Tested up to: 4.0-beta1 7 7 Stable tag: trunk 8 8 License: GPLv2 or later … … 16 16 17 17 The main project page is located here: [http://sterlinghamilton.com/projects/scalable-vector-graphics-svg/](http://sterlinghamilton.com/projects/scalable-vector-graphics-svg/ "Scalable Vector Graphics (SVG) | Sterling Hamilton") 18 19 Warning: Understanding that uploading any file to the system is a potential security risk, it is strongly recommended to only let trusted users to have upload privileges. 20 21 Resources for understanding security risks: 22 * http://security.stackexchange.com/questions/11384/exploits-or-other-security-risks-with-svg-upload 23 * https://www.youtube.com/watch?v=v-a77QdoK2I 18 24 19 25 == Installation == … … 38 44 * IMPORTANT: Anyone using the version prior to 2.0 were using shortcodes to display SVG files. You will have to go back and replace those shortcodes with actual image tags. If you're not familiar with HTML, you can just delete the shortcode out of the page/post and then insert the SVG file as you would any other image. 39 45 * Thanks to the guys over at mozilla.org for kicking me in the butt to actually fix this thing: https://bugzilla.mozilla.org/show_bug.cgi?id=721830 46 = 2.2.1 = 47 * Added a security library to scan all uploaded SVG files. It has a list of "expected" elements and attributes, if the file contains thing it does not expect, it removes them. This will include things like Javascript. 48 * The security cannot be perfect and it is recommended to only provide upload privileges to trusted users. 49 * Props to thedwards for bringing this to my attention. 50 = 2.3.1 = 51 * Added inline styling to tha administration area so SVG attachments will show up in list/grid views. 52 * Props to shield-9 (Daisuke Takahashi) for the code. -
scalable-vector-graphics-svg/trunk/scalable-vector-graphics.php
r909302 r949454 4 4 * Plugin URI: http://sterlinghamilton.com/projects/scalable-vector-graphics-svg/ 5 5 * Description: Scalable Vector Graphics are two-dimensional vector graphics, that can be both static and dynamic. This plugin allows your to easily use them on your site. 6 * Version: 2. 1.16 * Version: 2.3.1 7 7 * Author: Sterling Hamilton 8 8 * Author URI: http://sterlinghamilton.com … … 28 28 public function execute() { 29 29 $this->_enable_svg_mime_type(); 30 add_filter( 'wp_handle_upload_prefilter', array( $this, 'sanitize_svg' ) ); 31 add_action( 'admin_enqueue_scripts', array( $this, 'styles' ) ); 32 } 33 34 // Here we use a whitelist library to attempt at sanitizing potential security threats. 35 public function sanitize_svg( $file ) { 36 if( $file[ 'type' ] == 'image/svg+xml' ) { 37 require_once 'library/class.svg-sanitizer.php'; 38 39 $svg = new SvgSanitizer(); 40 // We read in the temporary file prior to WordPress moving it. 41 $svg->load( $file[ 'tmp_name' ] ); 42 $svg->sanitize(); 43 $sanitized_svg = $svg->saveSVG(); 44 45 global $wp_filesystem; 46 $creds = request_filesystem_credentials(site_url() . '/wp-admin/', '', FALSE, FALSE, array()); 47 if ( ! WP_Filesystem( $creds ) ) { 48 request_filesystem_credentials( $url, '', TRUE, FALSE, NULL ); 49 } 50 51 // Using the filesystem API provided by WordPress, we replace the contents of the temporary file and then let the process continue as normal. 52 $replace_uploaded_file = $wp_filesystem->put_contents($file['tmp_name'], $sanitized_svg, FS_CHMOD_FILE); 53 } 54 55 return $file; 30 56 } 31 57 … … 44 70 } 45 71 72 public function styles() { 73 wp_add_inline_style( 'wp-admin', "img.attachment-80x60[src$='.svg'] { width: 100%; height: auto; }" ); 74 } 46 75 } 47 76
Note: See TracChangeset
for help on using the changeset viewer.