mumukit-content-type 1.3.1 → 1.4.0
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
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4fdf9d6b5af5bcdb4de689b9a5489880aca70a4b9dabd7343e3c7510026b4149
|
|
4
|
+
data.tar.gz: 143fba3f1f5cc5e9cd4410019d57a984bc3d1e12e20341bbb608dcf007b3833a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: dd20954abd94ceaceb2d6a9ff2310d843a1410a5b94b8d7352d06dd62330cca4469626380ee7f1d581dfdc549d3be35f8b612b204e0d8ffb8db8238170006c0a
|
|
7
|
+
data.tar.gz: 646b6a9b35e54dbd33de377bb08b386a4e6c2d1fbfdfa0d2a926a9b402625e6b110ad723d31736f59d9765921d0bc396ff2c0a34ce11b438e52348da0f9c2ad9
|
data/lib/mumukit/content_type.rb
CHANGED
|
@@ -7,6 +7,10 @@ module Mumukit
|
|
|
7
7
|
def format_exception(e)
|
|
8
8
|
"#{title e.message}\n#{code e.backtrace.join("\n")}"
|
|
9
9
|
end
|
|
10
|
+
|
|
11
|
+
def to_html(content)
|
|
12
|
+
Mumukit::ContentType::Sanitizer.sanitize(htmlize content).html_safe
|
|
13
|
+
end
|
|
10
14
|
end
|
|
11
15
|
|
|
12
16
|
def self.parse(s)
|
|
@@ -21,6 +25,7 @@ module Mumukit
|
|
|
21
25
|
end
|
|
22
26
|
end
|
|
23
27
|
|
|
28
|
+
require_relative './content_type/sanitizer'
|
|
24
29
|
require_relative './content_type/emoji'
|
|
25
30
|
require_relative './content_type/markdown'
|
|
26
31
|
require_relative './content_type/with_markdown'
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
require 'sanitize'
|
|
2
|
+
|
|
3
|
+
module Mumukit::ContentType::Sanitizer
|
|
4
|
+
class << self
|
|
5
|
+
class_attribute :should_sanitize, :allowed_elements, :allowed_attributes
|
|
6
|
+
|
|
7
|
+
self.should_sanitize = false
|
|
8
|
+
self.allowed_elements = []
|
|
9
|
+
self.allowed_attributes = {
|
|
10
|
+
'a' => Sanitize::Config::RELAXED[:attributes]['a'] + ['target']
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
def sanitize(html)
|
|
14
|
+
return html unless should_sanitize?
|
|
15
|
+
|
|
16
|
+
Sanitize.fragment(html, sanitization_settings)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def sanitization_settings
|
|
20
|
+
Sanitize::Config.merge(Sanitize::Config::RELAXED, custom_sanitization_settings)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def custom_sanitization_settings
|
|
24
|
+
{
|
|
25
|
+
elements: Sanitize::Config::RELAXED[:elements] + allowed_elements,
|
|
26
|
+
attributes: allowed_attributes
|
|
27
|
+
}
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: mumukit-content-type
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.4.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Franco Leonardo Bulgarelli
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2018-
|
|
11
|
+
date: 2018-10-28 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -94,6 +94,20 @@ dependencies:
|
|
|
94
94
|
- - "~>"
|
|
95
95
|
- !ruby/object:Gem::Version
|
|
96
96
|
version: '1.0'
|
|
97
|
+
- !ruby/object:Gem::Dependency
|
|
98
|
+
name: sanitize
|
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
|
100
|
+
requirements:
|
|
101
|
+
- - "~>"
|
|
102
|
+
- !ruby/object:Gem::Version
|
|
103
|
+
version: '5.0'
|
|
104
|
+
type: :runtime
|
|
105
|
+
prerelease: false
|
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
107
|
+
requirements:
|
|
108
|
+
- - "~>"
|
|
109
|
+
- !ruby/object:Gem::Version
|
|
110
|
+
version: '5.0'
|
|
97
111
|
description:
|
|
98
112
|
email:
|
|
99
113
|
- franco@mumuki.org
|
|
@@ -107,6 +121,7 @@ files:
|
|
|
107
121
|
- lib/mumukit/content_type/html.rb
|
|
108
122
|
- lib/mumukit/content_type/markdown.rb
|
|
109
123
|
- lib/mumukit/content_type/plain.rb
|
|
124
|
+
- lib/mumukit/content_type/sanitizer.rb
|
|
110
125
|
- lib/mumukit/content_type/version.rb
|
|
111
126
|
- lib/mumukit/content_type/with_markdown.rb
|
|
112
127
|
- vendor/assets/images/emojis/-1.png
|
|
@@ -1012,7 +1027,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
1012
1027
|
version: '0'
|
|
1013
1028
|
requirements: []
|
|
1014
1029
|
rubyforge_project:
|
|
1015
|
-
rubygems_version: 2.7.
|
|
1030
|
+
rubygems_version: 2.7.7
|
|
1016
1031
|
signing_key:
|
|
1017
1032
|
specification_version: 4
|
|
1018
1033
|
summary: Content Type handling for Mumuki
|