Plugin Directory

Changeset 949454


Ignore:
Timestamp:
07/16/2014 08:13:53 AM (12 years ago)
Author:
sterlo
Message:

Update to latest v2.3.1 codebase from GitHub.

Location:
scalable-vector-graphics-svg/trunk
Files:
3 added
2 edited

Legend:

Unmodified
Added
Removed
  • scalable-vector-graphics-svg/trunk/readme.txt

    r909301 r949454  
    44Tags: svg, scalable, vector, graphics, mime, type, images, uploads
    55Requires at least: 3.0
    6 Tested up to: 3.9
     6Tested up to: 4.0-beta1
    77Stable tag: trunk
    88License: GPLv2 or later
     
    1616
    1717The 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
     19Warning: 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
     21Resources 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
    1824
    1925== Installation ==
     
    3844* 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.
    3945* 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  
    44 * Plugin URI: http://sterlinghamilton.com/projects/scalable-vector-graphics-svg/
    55 * 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.1
     6 * Version: 2.3.1
    77 * Author: Sterling Hamilton
    88 * Author URI: http://sterlinghamilton.com
     
    2828    public function execute() {
    2929        $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;
    3056    }
    3157
     
    4470    }
    4571
     72    public function styles() {
     73        wp_add_inline_style( 'wp-admin', "img.attachment-80x60[src$='.svg'] { width: 100%; height: auto; }" );
     74    }
    4675}
    4776
Note: See TracChangeset for help on using the changeset viewer.