roadie 3.1.1 → 3.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dc05f1423ea7579bcf0dbe77db9fca005476eab1
4
- data.tar.gz: 28839fad6470f4b466346d63d0b0b3a96ae7e612
3
+ metadata.gz: 05621c67077ec54a4f4dcc2ab3fcb67c284b4f38
4
+ data.tar.gz: 2a112599b37195701647caf2fb10cd03838f113c
5
5
  SHA512:
6
- metadata.gz: e62a3b9333e939b9c16b811f3d37ef3db08cd086e15d43fe13f932045af71bfc6551a9a9c57b6f89398c9a8bd5fe5af091e1ef66109149e621a8d3f329f9e9be
7
- data.tar.gz: 2c851d5ca9539fbf2db20368b8d7178a9d433e24541f26534416c0720afdc1b5fcfd55d4ff0d4188e3f3e2a9c66e43a2360d8563e3e5125838e4af4deedd22ae
6
+ metadata.gz: 3f689cd3d12c8e5ee73fe82eb82f8c27648b7cd5919f178501fc69f47073f3d10e335f66061c1ef35c5311a3d7f42a5694a9cb3238abbeea600627cd2edc308a
7
+ data.tar.gz: 9d459995a266fe9b0f186a980b4325b6fb2446f26b7eda6983d8a16cb38277aec81545aad9e170c8dd01a7c0658ec10fc12bd6b81c562f07a876ba51e750141b
@@ -1,17 +1,20 @@
1
1
  sudo: false
2
2
  language: ruby
3
3
  rvm:
4
- - 1.9.3
5
- - 2.0
6
4
  - 2.1
7
5
  - 2.2
6
+ - 2.3.0
8
7
  - jruby
9
8
  - rbx
10
9
 
10
+ matrix:
11
+ allow_failures:
12
+ # Rubinius has a lot of trouble and no large following, so I'm going to
13
+ # allow failures on it until it gets more stable on Travis / Real Life(tm).
14
+ # Let me know if you need it. Patches are welcome!
15
+ - rvm: rbx
16
+ fast_finish: true
17
+
11
18
  cache: bundler
12
19
  bundler_args: --without guard
13
20
  script: "rake"
14
-
15
- env:
16
- # Setup Coveralls
17
- secure: "D1Uvi+a7W89k91zXVVwuuvv8O8qbDdyJ4g9i+3bGaSYySHxD8YuuG1QiQ4G/S2KLp/r3VPRpa8Wb1mSwb81tEBzXpzoZC7zSvgntPxRPhMg4zpodZ0O0AkK8/t1yZSkIe0V5sejFOQ1a5LJa3OorKBBjrqM5kPDOygTXtO3bQ6E="
@@ -1,6 +1,23 @@
1
1
  ### dev
2
2
 
3
- [full changelog](https://github.com/Mange/roadie/compare/v3.1.1...master)
3
+ [full changelog](https://github.com/Mange/roadie/compare/v3.2.0...master)
4
+
5
+ * Nothing yet.
6
+
7
+ ### 3.2.0
8
+
9
+ [full changelog](https://github.com/Mange/roadie/compare/v3.1.1...v3.2.0)
10
+
11
+ * Deprecations:
12
+ * Dropped support for MRI 1.9.3.
13
+ * Dropped support for MRI 2.0.
14
+ * Upgrades:
15
+ * Use `css_parser` 1.4.x instead of 1.3.x.
16
+ * Bug fixes:
17
+ * Strip UTF-8 BOM (Byte Order Mark) from stylesheets before parsing / concatenating - [Bartłomiej Wójtowicz](https://github.com/qbart) (#128)
18
+ * Enhancements:
19
+ * Build against Ruby MRI 2.3.0 too.
20
+ * Don't add extra whitespace between table cells.
4
21
 
5
22
  ### 3.1.1
6
23
 
data/Gemfile CHANGED
@@ -2,7 +2,7 @@ source 'https://rubygems.org'
2
2
  gemspec
3
3
 
4
4
  # Added here so it does not show up on the Gemspec; I only want it for CI builds
5
- gem 'coveralls', group: :test, require: nil
5
+ gem 'codecov', group: :test, require: false
6
6
 
7
7
  group :guard do
8
8
  gem 'guard'
@@ -1,4 +1,4 @@
1
- Copyright (c) 2009 Jim Neath / Purify
1
+ Copyright (c) 2009-2016 Magnus Bergmark, Jim Neath / Purify, and contributors.
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -3,7 +3,7 @@ Roadie
3
3
 
4
4
  [![Build history and status](https://travis-ci.org/Mange/roadie.svg?branch=master)](http://travis-ci.org/#!/Mange/roadie)
5
5
  [![Code Climate](https://codeclimate.com/github/Mange/roadie.png)](https://codeclimate.com/github/Mange/roadie)
6
- [![Coverage Status](https://coveralls.io/repos/Mange/roadie/badge.png?branch=master)](https://coveralls.io/r/Mange/roadie?branch=master)
6
+ [![Code coverage status](https://codecov.io/github/Mange/roadie/coverage.svg?branch=master)](https://codecov.io/github/Mange/roadie?branch=master)
7
7
  [![Gem Version](https://badge.fury.io/rb/roadie.png)](http://badge.fury.io/rb/roadie)
8
8
  [![Dependency Status](https://gemnasium.com/Mange/roadie.png)](https://gemnasium.com/Mange/roadie)
9
9
 
@@ -19,7 +19,7 @@ How does it work?
19
19
 
20
20
  Email clients have bad support for stylesheets, and some of them blocks stylesheets from downloading. The easiest way to handle this is to work with inline styles (`style="..."`), but that is error prone and hard to work with as you cannot use classes and/or reuse styling over your HTML.
21
21
 
22
- This gem makes this easier by automatically inlining stylesheets into the document. You give Roadie your CSS, or let it find it by itself from the `<link>` and `<style>` tags in the markup, and it will go though all of the selectors assigning the styles to the maching elements. Careful attention has been put into selectors being applied in the correct order, so it should behave just like in the browser.
22
+ This gem makes this easier by automatically inlining stylesheets into the document. You give Roadie your CSS, or let it find it by itself from the `<link>` and `<style>` tags in the markup, and it will go through all of the selectors assigning the styles to the matching elements. Careful attention has been put into selectors being applied in the correct order, so it should behave just like in the browser.
23
23
 
24
24
  "Dynamic" selectors (`:hover`, `:visited`, `:focus`, etc.), or selectors not understood by Nokogiri will be inlined into a single `<style>` element for those email clients that support it. This changes specificity a great deal for these rules, so it might not work 100% out of the box. (See more about this below)
25
25
 
@@ -383,12 +383,11 @@ Build Status
383
383
 
384
384
  Tested with [Travis CI](http://travis-ci.org) using:
385
385
 
386
- * MRI 1.9.3
387
- * MRI 2.0
388
386
  * MRI 2.1
389
387
  * MRI 2.2
388
+ * MRI 2.3.0
390
389
  * JRuby (latest)
391
- * Rubinius >= 2.1
390
+ * Rubinius (failures on Rubinius will not fail the build due to a long history of instability in `rbx`)
392
391
 
393
392
  [(Build status)](http://travis-ci.org/#!/Mange/roadie)
394
393
 
@@ -433,6 +432,17 @@ bundle install
433
432
  rake
434
433
  ```
435
434
 
435
+ Security
436
+ --------
437
+
438
+ Roadie is set up with the assumption that all CSS and HTML passing through it is under your control. It is not recommended to run arbritary HTML with the default settings.
439
+
440
+ Care has been given to try to secure all file system accesses, but it is never guaranteed that someone cannot access something they should not be able to access.
441
+
442
+ In order to secure Roadie against file system access, only use your own asset providers that you yourself can secure against your particular environment.
443
+
444
+ If you have found any security vulnerability, please email me at `magnus.bergmark+security@gmail.com` to disclose it. [For very sensitive issues, please use my public GPG key.][gpg] You can also encrypt your message with my public key and open an issue if you do not want to email me directly. Thank you.
445
+
436
446
  History and contributors
437
447
  ------------------------
438
448
 
@@ -451,7 +461,7 @@ License
451
461
 
452
462
  (The MIT License)
453
463
 
454
- Copyright (c) 2009-2015
464
+ Copyright (c) 2009-2016 Magnus Bergmark, Jim Neath / Purify, and contributors.
455
465
 
456
466
  * [Magnus Bergmark](https://github.com/Mange) <magnus.bergmark@gmail.com>
457
467
 
@@ -461,3 +471,4 @@ The above copyright notice and this permission notice shall be included in all c
461
471
 
462
472
  THE SOFTWARE IS PROVIDED ‘AS IS’, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
463
473
 
474
+ [gpg]: https://gist.github.com/Mange/baf25e23e653a206ec2d#file-keybase-md
@@ -67,8 +67,7 @@ module Roadie
67
67
 
68
68
  callback after_transformation, dom
69
69
 
70
- # #dup is called since it fixed a few segfaults in certain versions of Nokogiri
71
- dom.dup.to_html
70
+ serialize_document dom
72
71
  end
73
72
 
74
73
  # Assign new normal asset providers. The supplied list will be wrapped in a {ProviderList} using {ProviderList.wrap}.
@@ -99,6 +98,16 @@ module Roadie
99
98
  make_url_rewriter.transform_dom(dom)
100
99
  end
101
100
 
101
+ def serialize_document(dom)
102
+ # #dup is called since it fixed a few segfaults in certain versions of Nokogiri
103
+ save_options = Nokogiri::XML::Node::SaveOptions
104
+ dom.dup.to_html(
105
+ save_with: (
106
+ save_options::NO_DECLARATION | save_options::NO_EMPTY_TAGS | save_options::AS_HTML
107
+ )
108
+ )
109
+ end
110
+
102
111
  def make_url_rewriter
103
112
  if url_options
104
113
  UrlRewriter.new(UrlGenerator.new(url_options))
@@ -2,7 +2,6 @@
2
2
  require 'set'
3
3
  require 'uri'
4
4
  require 'net/http'
5
- require 'net/https' # For Ruby 1.9.3 support
6
5
 
7
6
  module Roadie
8
7
  # @api public
@@ -6,6 +6,8 @@ module Roadie
6
6
  # @attr_reader [String] name the name of the stylesheet ("stylesheets/main.css", "Admin user styles", etc.). The name of the stylesheet will be visible if any errors occur.
7
7
  # @attr_reader [Array<StyleBlock>] blocks
8
8
  class Stylesheet
9
+ BOM = "\xEF\xBB\xBF".force_encoding('UTF-8').freeze
10
+
9
11
  attr_reader :name, :blocks
10
12
 
11
13
  # Parses the CSS string into a {StyleBlock}s and stores it.
@@ -14,7 +16,7 @@ module Roadie
14
16
  # @param [String] css
15
17
  def initialize(name, css)
16
18
  @name = name
17
- @blocks = parse_blocks(css)
19
+ @blocks = parse_blocks(css.sub(BOM, ""))
18
20
  end
19
21
 
20
22
  # @yield [selector, properties]
@@ -1,3 +1,3 @@
1
1
  module Roadie
2
- VERSION = '3.1.1'
2
+ VERSION = '3.2.0'
3
3
  end
@@ -18,7 +18,7 @@ Gem::Specification.new do |s|
18
18
  s.required_ruby_version = ">= 1.9"
19
19
 
20
20
  s.add_dependency 'nokogiri', '>= 1.5.0', '< 1.7.0'
21
- s.add_dependency 'css_parser', '~> 1.3.4'
21
+ s.add_dependency 'css_parser', '~> 1.4.5'
22
22
 
23
23
  s.add_development_dependency 'rspec', '~> 3.0'
24
24
  s.add_development_dependency 'rspec-collection_matchers', '~> 1.0'
@@ -250,4 +250,25 @@ describe "Roadie functionality" do
250
250
  expect(result.at_css("body")["class"]).to eq("roadie")
251
251
  expect(result.at_css("span")).to be_nil
252
252
  end
253
+
254
+ it "does not add whitespace between table cells" do
255
+ document = Roadie::Document.new <<-HTML
256
+ <html>
257
+ <body>
258
+ <table>
259
+ <tr>
260
+ <td>One</td><td>1</td>
261
+ </tr>
262
+ <tr>
263
+ <td>Two</td><td>2</td>
264
+ </tr>
265
+ </table>
266
+ </body>
267
+ </html>
268
+ HTML
269
+ result = document.transform
270
+
271
+ expect(result).to include("<td>One</td><td>1</td>")
272
+ expect(result).to include("<td>Two</td><td>2</td>")
273
+ end
253
274
  end
@@ -65,5 +65,11 @@ module Roadie
65
65
  Stylesheet.new("name", input)
66
66
  }.to_not change { input }.from(input_copy)
67
67
  end
68
+
69
+ it "strips UTF-8 Byte Order Mark" do
70
+ input = "\xEF\xBB\xBFbody { color: green; }"
71
+ stylesheet = Stylesheet.new("bom.css", input)
72
+ expect(stylesheet.to_s).to eq "body{color:green}"
73
+ end
68
74
  end
69
75
  end
@@ -2,8 +2,11 @@ require 'rspec/collection_matchers'
2
2
  require 'webmock/rspec'
3
3
 
4
4
  if ENV['CI']
5
- require 'coveralls'
6
- Coveralls.wear!
5
+ require 'simplecov'
6
+ SimpleCov.start
7
+
8
+ require 'codecov'
9
+ SimpleCov.formatter = SimpleCov::Formatter::Codecov
7
10
  end
8
11
 
9
12
  $: << File.dirname(__FILE__) + '/../lib'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: roadie
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.1
4
+ version: 3.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Magnus Bergmark
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-11 00:00:00.000000000 Z
11
+ date: 2016-10-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
@@ -36,14 +36,14 @@ dependencies:
36
36
  requirements:
37
37
  - - "~>"
38
38
  - !ruby/object:Gem::Version
39
- version: 1.3.4
39
+ version: 1.4.5
40
40
  type: :runtime
41
41
  prerelease: false
42
42
  version_requirements: !ruby/object:Gem::Requirement
43
43
  requirements:
44
44
  - - "~>"
45
45
  - !ruby/object:Gem::Version
46
- version: 1.3.4
46
+ version: 1.4.5
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rspec
49
49
  requirement: !ruby/object:Gem::Requirement
@@ -103,7 +103,7 @@ files:
103
103
  - Changelog.md
104
104
  - Gemfile
105
105
  - Guardfile
106
- - MIT-LICENSE
106
+ - LICENSE
107
107
  - README.md
108
108
  - Rakefile
109
109
  - autotest/discover.rb