rails-assets-markdown-it-sanitizer-0.4.1/0000755000004100000410000000000012633761651020430 5ustar www-datawww-datarails-assets-markdown-it-sanitizer-0.4.1/Rakefile0000644000004100000410000000003412633761651022072 0ustar www-datawww-datarequire "bundler/gem_tasks" rails-assets-markdown-it-sanitizer-0.4.1/Gemfile0000644000004100000410000000011112633761651021714 0ustar www-datawww-datasource 'https://rubygems.org' source 'https://rails-assets.org' gemspec rails-assets-markdown-it-sanitizer-0.4.1/lib/0000755000004100000410000000000012633761651021176 5ustar www-datawww-datarails-assets-markdown-it-sanitizer-0.4.1/lib/rails-assets-markdown-it-sanitizer/0000755000004100000410000000000012633761651030050 5ustar www-datawww-datarails-assets-markdown-it-sanitizer-0.4.1/lib/rails-assets-markdown-it-sanitizer/version.rb0000644000004100000410000000007612633761651032065 0ustar www-datawww-datamodule RailsAssetsMarkdownItSanitizer VERSION = "0.4.1" end rails-assets-markdown-it-sanitizer-0.4.1/lib/rails-assets-markdown-it-sanitizer.rb0000644000004100000410000000140712633761651030377 0ustar www-datawww-datarequire "rails-assets-markdown-it-sanitizer/version" module RailsAssetsMarkdownItSanitizer def self.gem_path Pathname(File.realpath(__FILE__)).join('../..') end def self.gem_spec Gem::Specification::load( gem_path.join("rails-assets-markdown-it-sanitizer.gemspec").to_s ) end def self.load_paths gem_path.join('app/assets').each_child.to_a end def self.dependencies [ ] end if defined?(Rails) class Engine < ::Rails::Engine # Rails -> use app/assets directory. end end end class RailsAssets @components ||= [] class << self attr_accessor :components def load_paths components.flat_map(&:load_paths) end end end RailsAssets.components << RailsAssetsMarkdownItSanitizer rails-assets-markdown-it-sanitizer-0.4.1/metadata.yml0000644000004100000410000000364012633761651022736 0ustar www-datawww-data--- !ruby/object:Gem::Specification name: rails-assets-markdown-it-sanitizer version: !ruby/object:Gem::Version version: 0.4.1 platform: ruby authors: - rails-assets.org autorequire: bindir: bin cert_chain: [] date: 2015-10-30 00:00:00.000000000 Z dependencies: - !ruby/object:Gem::Dependency name: bundler requirement: !ruby/object:Gem::Requirement requirements: - - ~> - !ruby/object:Gem::Version version: '1.3' type: :development prerelease: false version_requirements: !ruby/object:Gem::Requirement requirements: - - ~> - !ruby/object:Gem::Version version: '1.3' - !ruby/object:Gem::Dependency name: rake requirement: !ruby/object:Gem::Requirement requirements: - - '>=' - !ruby/object:Gem::Version version: '0' type: :development prerelease: false version_requirements: !ruby/object:Gem::Requirement requirements: - - '>=' - !ruby/object:Gem::Version version: '0' description: sanitizer for markdown-it. email: executables: [] extensions: [] extra_rdoc_files: [] files: - Gemfile - README.md - Rakefile - app/assets/javascripts/markdown-it-sanitizer.js - app/assets/javascripts/markdown-it-sanitizer/markdown-it-sanitizer.js - lib/rails-assets-markdown-it-sanitizer.rb - lib/rails-assets-markdown-it-sanitizer/version.rb - rails-assets-markdown-it-sanitizer.gemspec homepage: https://github.com/svbergerem/markdown-it-sanitizer licenses: - MIT metadata: {} post_install_message: rdoc_options: [] require_paths: - lib required_ruby_version: !ruby/object:Gem::Requirement requirements: - - '>=' - !ruby/object:Gem::Version version: '0' required_rubygems_version: !ruby/object:Gem::Requirement requirements: - - '>=' - !ruby/object:Gem::Version version: '0' requirements: [] rubyforge_project: rubygems_version: 2.4.8 signing_key: specification_version: 4 summary: sanitizer for markdown-it. test_files: [] rails-assets-markdown-it-sanitizer-0.4.1/rails-assets-markdown-it-sanitizer.gemspec0000644000004100000410000000140712633761651030651 0ustar www-datawww-data# coding: utf-8 lib = File.expand_path('../lib', __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'rails-assets-markdown-it-sanitizer/version' Gem::Specification.new do |spec| spec.name = "rails-assets-markdown-it-sanitizer" spec.version = RailsAssetsMarkdownItSanitizer::VERSION spec.authors = ["rails-assets.org"] spec.description = "sanitizer for markdown-it." spec.summary = "sanitizer for markdown-it." spec.homepage = "https://github.com/svbergerem/markdown-it-sanitizer" spec.license = "MIT" spec.files = `find ./* -type f | cut -b 3-`.split($/) spec.require_paths = ["lib"] spec.add_development_dependency "bundler", "~> 1.3" spec.add_development_dependency "rake" end rails-assets-markdown-it-sanitizer-0.4.1/app/0000755000004100000410000000000012633761651021210 5ustar www-datawww-datarails-assets-markdown-it-sanitizer-0.4.1/app/assets/0000755000004100000410000000000012633761651022512 5ustar www-datawww-datarails-assets-markdown-it-sanitizer-0.4.1/app/assets/javascripts/0000755000004100000410000000000012633761651025043 5ustar www-datawww-datarails-assets-markdown-it-sanitizer-0.4.1/app/assets/javascripts/markdown-it-sanitizer/0000755000004100000410000000000012633761651031305 5ustar www-datawww-data././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootrails-assets-markdown-it-sanitizer-0.4.1/app/assets/javascripts/markdown-it-sanitizer/markdown-it-sanitizer.jsrails-assets-markdown-it-sanitizer-0.4.1/app/assets/javascripts/markdown-it-sanitizer/markdown-it-sa0000644000004100000410000002106512633761651034071 0ustar www-datawww-data/*! markdown-it-sanitizer 0.4.1 https://github.com/svbergerem/markdown-it-sanitizer @license MIT */(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.markdownitSanitizer = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o var patternLinkOpen = ']*)"(?:\\stitle="([^"<>]*)")?>'; var regexpLinkOpen = RegExp(patternLinkOpen, 'i'); // var patternImage = ']*src="[^"<>]*"[^<>]*)\\s?\\/?>'; var regexpImage = RegExp(patternImage, 'i'); /* * it starts with '<' and maybe ends with '>', * maybe has a '<' on the right * it doesnt have '<' or '>' in between * -> it's a tag! */ str = str.replace(/<[^<>]*>?/gi, function (tag) { var match, url, alt, title, tagnameIndex; // '<->', '<- ' and '<3 ' look nice, they are harmless if (/(^<->|^<-\s|^<3\s)/.test(tag)) { return tag; } // images match = tag.match(regexpImage); if (match) { var attrs = match[1]; url = getUrl(attrs.match(/src="([^"<>]*)"/i)[1]); alt = attrs.match(/alt="([^"<>]*)"/i); alt = (alt && typeof alt[1] !== 'undefined') ? alt[1] : ''; title = attrs.match(/title="([^"<>]*)"/i); title = (title && typeof title[1] !== 'undefined') ? title[1] : ''; // only http and https are allowed for images if (url && /^https?:\/\//i.test(url)) { if (imageClass !== '') { return '' + alt + ''; } return '' + alt + ''; } } // links tagnameIndex = allowedTags.indexOf('a'); match = tag.match(regexpLinkOpen); if (match) { title = (typeof match[2] !== 'undefined') ? match[2] : ''; url = getUrl(match[1]); // only http, https, ftp, mailto and xmpp are allowed for links if (url && /^(?:https?:\/\/|ftp:\/\/|mailto:|xmpp:)/i.test(url)) { runBalancer = true; openTagCount[tagnameIndex] += 1; return ''; } } match = /<\/a>/i.test(tag); if (match) { runBalancer = true; openTagCount[tagnameIndex] -= 1; if (openTagCount[tagnameIndex] < 0) { removeTag[tagnameIndex] = true; } return ''; } // standalone tags match = tag.match(/<(br|hr)\s?\/?>/i); if (match) { return '<' + match[1].toLowerCase() + '>'; } // whitelisted tags match = tag.match(/<(\/?)(b|blockquote|code|em|h[1-6]|li|ol(?: start="\d+")?|p|pre|s|sub|sup|strong|ul)>/i); if (match && !/<\/ol start="\d+"/i.test(tag)) { runBalancer = true; tagnameIndex = allowedTags.indexOf(match[2].toLowerCase().split(' ')[0]); if (match[1] === '/') { openTagCount[tagnameIndex] -= 1; } else { openTagCount[tagnameIndex] += 1; } if (openTagCount[tagnameIndex] < 0) { removeTag[tagnameIndex] = true; } return '<' + match[1] + match[2].toLowerCase() + '>'; } // other tags we don't recognize if (removeUnknown === true) { return ''; } return escapeHtml(tag); }); return str; } function sanitizeInlineAndBlock(state) { var i, blkIdx, inlineTokens; // reset counts for (j = 0; j < allowedTags.length; j++) { openTagCount[j] = 0; } for (j = 0; j < allowedTags.length; j++) { removeTag[j] = false; } runBalancer = false; for (blkIdx = 0; blkIdx < state.tokens.length; blkIdx++) { if (state.tokens[blkIdx].type === 'html_block') { state.tokens[blkIdx].content = replaceUnknownTags(state.tokens[blkIdx].content); } if (state.tokens[blkIdx].type !== 'inline') { continue; } inlineTokens = state.tokens[blkIdx].children; for (i = 0; i < inlineTokens.length; i++) { if (inlineTokens[i].type === 'html_inline') { inlineTokens[i].content = replaceUnknownTags(inlineTokens[i].content); } } } } ///////////////////////////////////////////////////////////////////////////////////////////////// // REPLACE UNBALANCED TAGS ///////////////////////////////////////////////////////////////////////////////////////////////// function balance(state) { if (runBalancer === false) { return; } var blkIdx, inlineTokens; function replaceUnbalancedTag(str, tagname) { var openingRegexp, closingRegexp; if (tagname === 'a') { openingRegexp = RegExp(']*" title="[^"<>]*" target="_blank">', 'g'); } else if (tagname === 'ol') { openingRegexp = //g; } else { openingRegexp = RegExp('<' + tagname + '>', 'g'); } closingRegexp = RegExp('', 'g'); if (removeUnbalanced === true) { str = str.replace(openingRegexp, ''); str = str.replace(closingRegexp, ''); } else { str = str.replace(openingRegexp, function(m) { return escapeHtml(m); }); str = str.replace(closingRegexp, function(m) { return escapeHtml(m); }); } return str; } function replaceAllUnbalancedTags(str) { var i; for (i = 0; i < allowedTags.length; i++) { if (removeTag[i] === true) { str = replaceUnbalancedTag(str, allowedTags[i]); } } return str; } for (j = 0; j < allowedTags.length; j++) { if (openTagCount[j] !== 0) { removeTag[j] = true; } } // replace unbalanced tags for (blkIdx = 0; blkIdx < state.tokens.length; blkIdx++) { if (state.tokens[blkIdx].type === 'html_block') { state.tokens[blkIdx].content = replaceAllUnbalancedTags(state.tokens[blkIdx].content); continue; } if (state.tokens[blkIdx].type !== 'inline') { continue; } inlineTokens = state.tokens[blkIdx].children; for (j = 0; j < inlineTokens.length; j++) { if (inlineTokens[j].type === 'html_inline') { inlineTokens[j].content = replaceAllUnbalancedTags(inlineTokens[j].content); } } } } md.core.ruler.after('linkify', 'sanitize_inline', sanitizeInlineAndBlock); md.core.ruler.after('sanitize_inline', 'sanitize_balance', balance); }; },{}]},{},[1])(1) });rails-assets-markdown-it-sanitizer-0.4.1/app/assets/javascripts/markdown-it-sanitizer.js0000644000004100000410000000007312633761651031643 0ustar www-datawww-data//= require markdown-it-sanitizer/markdown-it-sanitizer.js rails-assets-markdown-it-sanitizer-0.4.1/README.md0000644000004100000410000000071412633761651021711 0ustar www-datawww-data# rails-assets-markdown-it-sanitizer > The Bower package inside a gem This gem was automatically generated. You can visit [rails-assets.org](https://rails-assets.org) for more information. ## Usage Add rails-assets source block to your `Gemfile`: ```ruby source "https://rails-assets.org" do gem "rails-assets-markdown-it-sanitizer" end ``` Then, import the asset using Sprockets’ `require` directive: ```js //= require "markdown-it-sanitizer" ```