string_master 0.3.8 → 0.3.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4dda1d7c572babaf90cfe7be2777a2b7668416f6
4
- data.tar.gz: 81914454c060a63d1a57a5a77f542dc86bce209a
3
+ metadata.gz: 9014d6e022669d3f53cd4390ace1e70c6583087b
4
+ data.tar.gz: 445a71c28808806e006dee990fead2da4411dd12
5
5
  SHA512:
6
- metadata.gz: 3979d5c8e3acd3eb1d6ce855200666322913981aa52cd29ec7374db75342f4378b6b7a57b08ccebc16ee3d8e3453e772fbe1b20d18a62290123109c553c14c1e
7
- data.tar.gz: 36010284b756e6466badb3920f97567aed71b1af68ad65b204d5a0c05b67795564cd020e48ffa8f6e6bd9cb298d29221fd312e11f680672804be8e6ae603a8de
6
+ metadata.gz: 8a7dd75b86a3c35b2fbd90897fdcdb8a064a6f1650402dc4461548e893fe0761b084bd4ca34f8f35134b5927040cf30ae116eec6455888d58b49944b94bfeee4
7
+ data.tar.gz: f8b2bd2821bb6d6e07c4fda1fbe0b49f841424a463574efa4d4d068212756d6708667096be65222ded25626d6ed961555b3a11944895356fa6350920e58d0c95
data/Gemfile.lock CHANGED
@@ -54,7 +54,7 @@ GEM
54
54
  loofah (2.0.2)
55
55
  nokogiri (>= 1.5.9)
56
56
  mini_portile (0.6.2)
57
- minitest (5.7.0)
57
+ minitest (5.8.0)
58
58
  multi_json (1.11.2)
59
59
  multi_xml (0.5.5)
60
60
  multipart-post (2.0.0)
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.8
1
+ 0.3.9
@@ -33,10 +33,12 @@ class StringMaster
33
33
  def html_escape(options={})
34
34
  except = options[:except] || %w()
35
35
  close_tags
36
- @modified_string.gsub!(/<\/?([a-zA-Z0-9]*?)(\s[^>]*)?>/) do |tag|
36
+ @modified_string.gsub!(/<\/?([a-zA-Z0-9]*?)(\s[^>]*?)?>/) do |tag|
37
37
  if except.include?($1)
38
- # Really sanitizes attributes only here
39
- sanitize(tag, :tags => except, :attributes => %w(href src lang))
38
+ # sanitize attributes
39
+ tag.gsub(/(\s.+?)=('|").*?\2(?=.*?>)/) do |a|
40
+ ["href", "src", "lang"].include?($1) ? a : ""
41
+ end
40
42
  else
41
43
  h(tag)
42
44
  end
@@ -9,7 +9,9 @@ describe StringMaster do
9
9
 
10
10
  it "escapes html except for some of the allowed tags" do
11
11
  parser = StringMaster.new('<img src="#" style="border: solid 1px green;"><b>Hello</b>')
12
- parser.html_escape(:except => %w(img)).string.should == '<img src="#">&lt;b&gt;Hello&lt;/b&gt;'
12
+ parser.html_escape(:except => %w(img)).string.should == '<img>&lt;b&gt;Hello&lt;/b&gt;'
13
+ parser = StringMaster.new('<i>hello</i> <b>world</b>')
14
+ parser.html_escape(:except => %w(b)).to_s.should == '&lt;i&gt;hello&lt;/i&gt; <b>world</b>'
13
15
  end
14
16
 
15
17
  it "makes images of urls that end with .jpg and other image extensions" do
@@ -2,16 +2,16 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: string_master 0.3.8 ruby lib
5
+ # stub: string_master 0.3.9 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "string_master"
9
- s.version = "0.3.8"
9
+ s.version = "0.3.9"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib"]
13
13
  s.authors = ["Roman Snitko"]
14
- s.date = "2015-07-29"
14
+ s.date = "2015-08-13"
15
15
  s.description = "Because every time I create a new webapp, I think about how I should process user-generated content. Should convert urls to links and images? Should I allow certain tags? Should I convert all new lines to *br* tags? Well, now all that is as simple as calling a single method."
16
16
  s.email = "roman.snitko@gmail.com"
17
17
  s.extra_rdoc_files = [
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: string_master
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.8
4
+ version: 0.3.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Roman Snitko
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-29 00:00:00.000000000 Z
11
+ date: 2015-08-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionpack