Plugin Directory

Changeset 1149615


Ignore:
Timestamp:
04/29/2015 11:05:50 PM (11 years ago)
Author:
guavaworks
Message:

Adding HTML Janitor for sanitation - 1.2.2

Location:
angularjs-for-wp/trunk
Files:
1 added
7 edited

Legend:

Unmodified
Added
Removed
  • angularjs-for-wp/trunk/angularjs-templates/list-detail.html

    r931561 r1149615  
    3636<article>
    3737    <h2>{{post.title}}</h2>
    38     <div ng-bind-html="post.content | unsafe"></div>
     38    <div ng-bind-html="post.content | sanitize"></div>
    3939    <a href="{{post.link}}">Read More...</a>
    4040    <hr />
  • angularjs-for-wp/trunk/angularjs-templates/post-content.html

    r1132529 r1149615  
    22unlike other templates, you must use post.content_raw for this template.
    33-->
    4 
    5 <div ng-bind-html="content | unsafe"></div>
     4<pre>{{content | json }}</pre>
     5<div ng-bind-html='content | sanitize'></div>
  • angularjs-for-wp/trunk/angularjs-templates/single-detail.html

    r931561 r1149615  
    3636<article>
    3737    <h2>{{post.title}}</h2>
    38     <div ng-bind-html="post.content | unsafe"></div>
     38    <div ng-bind-html="post.content | sanitize"></div>
    3939    <a href="{{post.link}}">Read More...</a>
    4040    <hr />
  • angularjs-for-wp/trunk/includes/contentFilter.php

    r1132529 r1149615  
    66    $meta = get_post_meta($post->ID, 'angularjsLoad', true);
    77    $meta = intval($meta);
    8 
     8    $content = str_replace('"', '\'', $content );
     9           
    910    if($meta){
    1011        $content = '<div ng-app="wpAngularPlugin"><ng-post-content id="'.$post->ID.'" content="'.$content.'"></ng-post-content></div>';
  • angularjs-for-wp/trunk/js/angular-app.js

    r1132529 r1149615  
    11var angular_app = angular.module('wpAngularPlugin', ['ngSanitize']);
    22
    3 angular_app.filter('unsafe', function($sce) {
    4     return function(val) {
    5         if( $sce.trustAsHtml(val) )
    6             return $sce.trustAsHtml(val).toString();
     3angular_app.filter('unsafe', function ($sce) {
     4    return function (val) {
     5        return $sce.trustAsHtml(val);
     6    };
     7});
     8
     9var janitor = new HTMLJanitor({
     10    tags: {
     11        div: {
     12            id: true,
     13            class: true
     14        },
     15        p: {
     16            id: true,
     17            class: true
     18        },
     19        code: {},
     20        pre: {},
     21        // TODO: Map b => strong
     22        strong: {},
     23        b: {},
     24        // TODO: Map em => i
     25        em: {},
     26        i: {},
     27        // TODO: Map strike => del
     28        strike: {},
     29        del: {},
     30        a: { href: true },
     31        ul: {},
     32        ol: {},
     33        li: {},
     34        blockquote: {},
     35        h1: {},
     36        h2: {},
     37        h3: {},
     38        h4: {},
     39        h5: {},
     40        h6: {},
     41        sub: {},
     42        sup: {}
     43    }
     44});
     45
     46angular_app.filter('sanitize', function (unsafeFilter) {
     47    return function (val) {
     48        return unsafeFilter(janitor.clean(val));
    749    };
    850});
  • angularjs-for-wp/trunk/plugin.php

    r1149594 r1149615  
    44 * Plugin URI: http://www.roysivan.com/angularjs-for-wordpress
    55 * Description: This plugin will allow you to easily load WordPress content client-side using AngularJS. JSON REST API required.
    6  * Version: 1.2.1
     6 * Version: 1.2.2
    77 * Author: Roy Sivan
    88 * Author URI: http://www.roysivan.com
     
    1414require_once('includes/shortcodes.php');
    1515
    16 define('WordPressAngularJS', '1.2');
     16define('WordPressAngularJS', '1.2.2');
    1717
    1818class WordPressAngularJS {
     
    2727        wp_enqueue_script('angular-core', plugin_dir_url( __FILE__ ).'js/angular.min.js', array('jquery'), null, false);
    2828        wp_enqueue_script('angular-sanitize', plugin_dir_url( __FILE__ ).'js/angular-sanitize.min.js', array('jquery'), null, false);
    29         wp_enqueue_script('angular-app', plugin_dir_url( __FILE__ ).'js/angular-app.js', array('jquery'), null, false);
     29        wp_enqueue_script('html-janitor', plugin_dir_url( __FILE__ ).'js/html-janitor.js', array('jquery'), null, false);
     30       
     31        wp_enqueue_script('angular-app', plugin_dir_url( __FILE__ ).'js/angular-app.js', array('html-janitor'), null, false);
    3032
    3133        // Angular Factories
  • angularjs-for-wp/trunk/readme.txt

    r1149594 r1149615  
    55Requires at least: 3.9
    66Tested up to: 4.2.1
    7 Stable tag: 1.2.1
     7Stable tag: 1.2.2
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    7070= 1.2.1 =
    7171* Child Theme Support
     72
     73= 1.2.2 =
     74* Adding in HTML Janitor - [fixing issue](https://github.com/royboy789/angularjs-for-wordpress/issues/6)
Note: See TracChangeset for help on using the changeset viewer.