Skip to content

Commit

Permalink
TECH-16494 support Rails 7.x (#1)
Browse files Browse the repository at this point in the history
* TECH-16494 support Rails 7.x
  • Loading branch information
ttstarck authored Nov 4, 2024
1 parent 8b34840 commit 6c6ca25
Show file tree
Hide file tree
Showing 19 changed files with 132 additions and 33 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @Invoca/octothorpe
27 changes: 27 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
name: Rails Deprecated Sanitizer Gem Build
on: [push, pull_request]
jobs:
test:
name: Unit Tests
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
ruby: [3.1, 3.2, 3.3]
gemfile:
- Gemfile
- gemfiles/activesupport_6_1.gemfile
- gemfiles/activesupport_7_0.gemfile
- gemfiles/activesupport_7_1.gemfile
- gemfiles/activesupport_7_2.gemfile
env:
BUNDLE_GEMFILE: ${{ matrix.gemfile }}
steps:
- uses: actions/checkout@v2
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler: 2.5.10
bundler-cache: true
- run: bundle exec rake test
38 changes: 38 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
on:
push:
tags:
- 'v*'
- '!v*.pre*'

name: Create Release

jobs:
build:
name: Create Release
runs-on: ubuntu-latest
steps:
- name: Get version from tag
id: tag_name
shell: bash
run: |
echo ::set-output name=current_version::${GITHUB_REF#refs/tags/v}
- name: Checkout code
uses: actions/checkout@v2
- name: Get Changelog Entry
id: changelog_reader
uses: mindsers/changelog-reader-action@v1
with:
version: ${{ steps.tag_name.outputs.current_version }}
path: ./CHANGELOG.md
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GEM_RELEASE_GIT_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
body: ${{ steps.changelog_reader.outputs.log_entry }}
draft: false
prerelease: false
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,5 @@ tmp
*.o
*.a
mkmf.log
.idea
gemfiles/*.lock
1 change: 1 addition & 0 deletions .ruby-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.1.6
22 changes: 0 additions & 22 deletions .travis.yml

This file was deleted.

4 changes: 4 additions & 0 deletions Appraisals
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# frozen_string_literal: true

require "appraisal/matrix"
appraisal_matrix(activesupport: ">= 6.1")
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 1.0.5
* InvocaPatch: Add Rails 7.x support
* InvocaPatch: Require ruby 3.1 or higher

## 1.0.4

* Rails 6 support https://github.com/rails/rails-deprecated_sanitizer/pull/6
Expand Down
3 changes: 2 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
source 'https://rubygems.org'

gem 'rails', github: 'rails/rails'
gem "appraisal-matrix"
gem 'rails'

gemspec
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Rails::Deprecated::Sanitizer

## Invoca Patch
* Add support for Rails 7.0

In Rails 4.2 HTML sanitization has been rewritten using a more secure library.

This gem includes the old behavior shipping with Rails 4.2 and before. It is
Expand Down
9 changes: 9 additions & 0 deletions gemfiles/activesupport_6_1.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "appraisal-matrix"
gem "rails"
gem "activesupport", "~> 6.1.0"

gemspec path: "../"
9 changes: 9 additions & 0 deletions gemfiles/activesupport_7_0.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "appraisal-matrix"
gem "rails"
gem "activesupport", "~> 7.0.0"

gemspec path: "../"
9 changes: 9 additions & 0 deletions gemfiles/activesupport_7_1.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "appraisal-matrix"
gem "rails"
gem "activesupport", "~> 7.1.0"

gemspec path: "../"
9 changes: 9 additions & 0 deletions gemfiles/activesupport_7_2.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "appraisal-matrix"
gem "rails"
gem "activesupport", "~> 7.2.0"

gemspec path: "../"
8 changes: 4 additions & 4 deletions lib/rails/deprecated_sanitizer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@ module DeprecatedSanitizer
extend self

def full_sanitizer
HTML::FullSanitizer
::HTML::FullSanitizer
end

def link_sanitizer
HTML::LinkSanitizer
::HTML::LinkSanitizer
end

def white_list_sanitizer
HTML::WhiteListSanitizer
::HTML::WhiteListSanitizer
end

def safe_list_sanitizer
HTML::WhiteListSanitizer
::HTML::WhiteListSanitizer
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/rails/deprecated_sanitizer/railtie.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module Rails
module DeprecatedSanitizer
class Railtie < Rails::Railtie
config.eager_load_namespaces << HTML
config.eager_load_namespaces << ::HTML
end
end
end
2 changes: 1 addition & 1 deletion lib/rails/deprecated_sanitizer/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Rails
module DeprecatedSanitizer
VERSION = "1.0.4"
VERSION = "1.0.5"
end
end
11 changes: 8 additions & 3 deletions rails-deprecated_sanitizer.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,20 @@ Gem::Specification.new do |spec|
spec.version = Rails::DeprecatedSanitizer::VERSION
spec.authors = ["Kasper Timm Hansen"]
spec.email = ["[email protected]"]
spec.summary = %q{Deprecated sanitizer API extracted from Action View.}
spec.homepage = "https://github.com/rails/rails-deprecated_sanitizer"
spec.summary = "Deprecated sanitizer API extracted from Action View."
spec.homepage = "https://github.com/Invoca/rails-deprecated_sanitizer"
spec.license = "MIT"

spec.files = Dir["CHANGELOG.md", "LICENSE", "README.md", "lib/**/*"]
spec.test_files = Dir["test/**/*.rb"]
spec.require_paths = ["lib"]

spec.add_dependency "activesupport", ">= 4.2.0.alpha"
spec.metadata = {
"allowed_push_host" => "https://gem.fury.io/invoca"
}
spec.required_ruby_version = ">= 3.1"

spec.add_dependency "activesupport", ">= 6.0"

spec.add_development_dependency "bundler", "~> 2.0"
spec.add_development_dependency "rake"
Expand Down
1 change: 0 additions & 1 deletion test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,4 @@
require 'rails/deprecated_sanitizer'

# Show backtraces for deprecated behavior for quicker cleanup.
ActiveSupport::Deprecation.debug = true
ActiveSupport::TestCase.test_order = :random

0 comments on commit 6c6ca25

Please sign in to comment.