ruby-exclaim 0.0.0 → 0.1.1
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 +4 -4
- data/.circleci/config.yml +8 -6
- data/.github/CODEOWNERS +1 -0
- data/CHANGELOG.md +9 -0
- data/README.md +17 -5
- data/lib/exclaim/bind.rb +18 -6
- data/lib/exclaim/implementations/example_implementation_map.rb +2 -3
- data/lib/exclaim/renderer.rb +3 -2
- data/lib/exclaim/ui.rb +3 -2
- data/lib/exclaim/version.rb +1 -1
- data/ruby-exclaim.gemspec +1 -1
- metadata +8 -7
- data/.github/workflows/release.yml +0 -29
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1c108c1900809559c4fbcd3b1488636b56190630bba66f5cdcaf620170c8d8e2
|
4
|
+
data.tar.gz: 61ec43e7d945f0e474bcd8778edc0c2b3119f3afcceaa30549f601f936c2bac0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 470364f3b893180ece919ab1ab315ad12315d6a6673e6cb98f42ac03f836caadf6a50431af5dd2046bf527ce2f42ff62129f9462ecd3a51b3d6ec5f7dccb67a2
|
7
|
+
data.tar.gz: e12ff894c269e62ff479ad1c31f404a5da049a2273d290ac2f132585731b9bc2167c0893e74a18c9ebad11619b9925790c8991de2546ed78a1e95ac0e03eb5b4
|
data/.circleci/config.yml
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
version: 2.1
|
2
|
+
|
2
3
|
workflows:
|
3
4
|
version: 2
|
4
5
|
ruby-exclaim:
|
@@ -8,18 +9,19 @@ workflows:
|
|
8
9
|
jobs:
|
9
10
|
build:
|
10
11
|
docker:
|
11
|
-
- image:
|
12
|
+
- image: $SALSIFY_ECR_REPO/ruby_ci:3.3.5
|
13
|
+
aws_auth:
|
14
|
+
aws_access_key_id: $ECR_AWS_ACCESS_KEY_ID
|
15
|
+
aws_secret_access_key: $ECR_AWS_SECRET_ACCESS_KEY
|
12
16
|
environment:
|
13
|
-
RACK_ENV: "test"
|
14
|
-
RAILS_ENV: "test"
|
15
17
|
CIRCLE_TEST_REPORTS: "test-results"
|
16
18
|
working_directory: ~/ruby-exclaim
|
17
19
|
steps:
|
18
20
|
- checkout
|
19
21
|
- restore_cache:
|
20
22
|
keys:
|
21
|
-
- v1-gems-ruby-
|
22
|
-
- v1-gems-ruby-
|
23
|
+
- v1-gems-ruby-3.3.5-{{ checksum "ruby-exclaim.gemspec" }}-{{ checksum "Gemfile" }}
|
24
|
+
- v1-gems-ruby-3.3.5-
|
23
25
|
- run:
|
24
26
|
name: Install Gems
|
25
27
|
command: |
|
@@ -28,7 +30,7 @@ jobs:
|
|
28
30
|
bundle clean
|
29
31
|
fi
|
30
32
|
- save_cache:
|
31
|
-
key: v1-gems-ruby-
|
33
|
+
key: v1-gems-ruby-3.3.5-{{ checksum "ruby-exclaim.gemspec" }}-{{ checksum "Gemfile" }}
|
32
34
|
paths:
|
33
35
|
- "vendor/bundle"
|
34
36
|
- "gemfiles/vendor/bundle"
|
data/.github/CODEOWNERS
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
* @skarger
|
data/CHANGELOG.md
CHANGED
@@ -6,6 +6,15 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
|
|
6
6
|
|
7
7
|
## Unreleased
|
8
8
|
|
9
|
+
## 0.1.1 - 2024-11-18
|
10
|
+
### Fixed
|
11
|
+
- Fix various issues related to path segments that appear to be numbers.
|
12
|
+
|
13
|
+
## 0.1.0 - 2021-05-06
|
14
|
+
### Added
|
15
|
+
- Ability to disable all HTML escaping by setting the `should_escape_html` flag to `false` when instantiating
|
16
|
+
`Exclaim::Ui`, e.g. `Exclaim::Ui.new(implementation_map: my_implementation_map, should_escape_html: false)`
|
17
|
+
|
9
18
|
## 0.0.0 - 2021-02-12
|
10
19
|
### Added
|
11
20
|
- Initial version
|
data/README.md
CHANGED
@@ -17,6 +17,7 @@
|
|
17
17
|
+ [Shorthand Properties and Configuration Defaults](#shorthand-properties-and-configuration-defaults)
|
18
18
|
+ [Security Considerations](#security-considerations)
|
19
19
|
- [Script Injection](#script-injection)
|
20
|
+
- [Disable HTML escaping](#disable-html-escaping)
|
20
21
|
- [Unintended Tracking/HTTP Requests](#unintended-trackinghttp-requests)
|
21
22
|
* [Querying the Parsed UI](#querying-the-parsed-ui)
|
22
23
|
* [Utilities](#utilities)
|
@@ -219,10 +220,8 @@ exclaim_ui.render(env: my_environment)
|
|
219
220
|
|
220
221
|
Dot-separated `$bind` paths dig into nested `env` values: `a.b.c` refers to `{ "a" => { "b" => { "c" => "value" } } }`
|
221
222
|
|
222
|
-
If a `$bind`
|
223
|
-
|
224
|
-
|
225
|
-
`"my_array.1"` refers to array index 1 in an `env` like `{ "my_array: ["zero", "one", ...] }`
|
223
|
+
If the field a `$bind` subpath refers is an Array, the next segment is assumed to be an integer. For example,
|
224
|
+
`"my_array.1"` refers to array index 1, value "zero" in an `env` like `{ "my_array: ["zero", "one", ...] }`.
|
226
225
|
|
227
226
|
### Implementing Components and Helpers
|
228
227
|
|
@@ -633,6 +632,19 @@ your implementation can call `CGI.unescape_html` or `CGI.unescape_element`.
|
|
633
632
|
See [CGI::Util](https://ruby-doc.org/stdlib-3.0.0/libdoc/cgi/rdoc/CGI/Util.html)
|
634
633
|
in the Ruby standard library for details.
|
635
634
|
|
635
|
+
##### Disable HTML escaping
|
636
|
+
|
637
|
+
You can disable HTML escaping altogether by setting the `should_escape_html` flag to `false` when instantiating
|
638
|
+
`Exclaim::Ui`. You generally should only do this when the output will not be rendered directly to HTML as this could
|
639
|
+
potentially allow script injection and other hazards of unescaped rendering of untrusted user input. If you use this
|
640
|
+
flag and the output is ultimately destined for a browser, make sure something downstream between `Exclaim::Ui#render`
|
641
|
+
and the browser will escape characters that have special meaning in HTML: `<` `>` `&` `"` `'`
|
642
|
+
|
643
|
+
```
|
644
|
+
exclaim_ui = Exclaim::Ui.new(implementation_map: my_implementation_map, should_escape_html: false)
|
645
|
+
exclaim_ui.render(env: my_environment) # HTML characters will not be escaped
|
646
|
+
```
|
647
|
+
|
636
648
|
##### Unintended Tracking/HTTP Requests
|
637
649
|
|
638
650
|
If you don't need to implement components with configurable URLs, just avoid it completely.
|
@@ -786,7 +798,7 @@ After checking out the repo, run `bin/setup` to install dependencies. Then,
|
|
786
798
|
run `rake spec` to run the tests. You can also run `bin/console` for an
|
787
799
|
interactive prompt that will allow you to experiment.
|
788
800
|
|
789
|
-
To install this gem onto your local machine, run `bundle exec rake install`.
|
801
|
+
To install this gem onto your local machine, run `bundle exec rake install`.
|
790
802
|
|
791
803
|
To release a new version, update the version number in `version.rb`. When merged
|
792
804
|
to the default branch, [a GitHub action](.github/workflows/release.yml) will
|
data/lib/exclaim/bind.rb
CHANGED
@@ -14,15 +14,27 @@ module Exclaim
|
|
14
14
|
def path=(value)
|
15
15
|
@path = value
|
16
16
|
@path_keys = @path.split('.')
|
17
|
-
@path_keys_for_arrays = @path_keys.map do |string|
|
18
|
-
Integer(string)
|
19
|
-
rescue ArgumentError, TypeError
|
20
|
-
string
|
21
|
-
end
|
22
17
|
end
|
23
18
|
|
24
19
|
def evaluate(env)
|
25
|
-
|
20
|
+
obj = env
|
21
|
+
|
22
|
+
@path_keys.each do |key|
|
23
|
+
return nil if !obj.is_a?(Hash) && !obj.is_a?(Array)
|
24
|
+
|
25
|
+
if obj.is_a?(Array)
|
26
|
+
key = begin
|
27
|
+
Integer(key)
|
28
|
+
rescue ArgumentError, TypeError
|
29
|
+
return nil
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
obj = obj[key]
|
34
|
+
return nil if obj.nil?
|
35
|
+
end
|
36
|
+
|
37
|
+
obj
|
26
38
|
end
|
27
39
|
end
|
28
40
|
end
|
@@ -14,8 +14,7 @@ module Exclaim
|
|
14
14
|
extend self
|
15
15
|
|
16
16
|
def example_implementation_map
|
17
|
-
@example_implementation_map ||=
|
18
|
-
{
|
17
|
+
@example_implementation_map ||= {
|
19
18
|
'each' => EACH_COMPONENT,
|
20
19
|
'image' => IMAGE_COMPONENT,
|
21
20
|
'if' => IF_HELPER,
|
@@ -25,7 +24,7 @@ module Exclaim
|
|
25
24
|
'text' => TEXT_COMPONENT,
|
26
25
|
'vbox' => VBOX_COMPONENT
|
27
26
|
}
|
28
|
-
|
27
|
+
|
29
28
|
end
|
30
29
|
end
|
31
30
|
end
|
data/lib/exclaim/renderer.rb
CHANGED
@@ -2,8 +2,9 @@
|
|
2
2
|
|
3
3
|
module Exclaim
|
4
4
|
class Renderer
|
5
|
-
def initialize(parsed_ui)
|
5
|
+
def initialize(parsed_ui, should_escape_html = true)
|
6
6
|
@parsed_ui = parsed_ui
|
7
|
+
@should_escape_html = should_escape_html
|
7
8
|
end
|
8
9
|
|
9
10
|
def call(env: {})
|
@@ -25,7 +26,7 @@ module Exclaim
|
|
25
26
|
end
|
26
27
|
|
27
28
|
def resolve_component_config(component, env)
|
28
|
-
resolve(component.config, env).transform_values! { |value| escape_html!(value) }
|
29
|
+
resolve(component.config, env).transform_values! { |value| @should_escape_html ? escape_html!(value) : value }
|
29
30
|
end
|
30
31
|
|
31
32
|
def escape_html!(value)
|
data/lib/exclaim/ui.rb
CHANGED
@@ -4,8 +4,9 @@ module Exclaim
|
|
4
4
|
class Ui
|
5
5
|
attr_reader :implementation_map, :parsed_ui, :renderer
|
6
6
|
|
7
|
-
def initialize(implementation_map: Exclaim::Implementations.example_implementation_map)
|
7
|
+
def initialize(implementation_map: Exclaim::Implementations.example_implementation_map, should_escape_html: true)
|
8
8
|
@implementation_map = Exclaim::ImplementationMap.parse!(implementation_map)
|
9
|
+
@should_escape_html = should_escape_html
|
9
10
|
rescue Exclaim::Error
|
10
11
|
raise
|
11
12
|
rescue StandardError => e
|
@@ -66,7 +67,7 @@ module Exclaim
|
|
66
67
|
|
67
68
|
def parsed_ui=(value)
|
68
69
|
@parsed_ui = value
|
69
|
-
@renderer = Exclaim::Renderer.new(@parsed_ui)
|
70
|
+
@renderer = Exclaim::Renderer.new(@parsed_ui, @should_escape_html)
|
70
71
|
end
|
71
72
|
|
72
73
|
def bind_paths(config_value, accumulator)
|
data/lib/exclaim/version.rb
CHANGED
data/ruby-exclaim.gemspec
CHANGED
@@ -20,7 +20,7 @@ Gem::Specification.new do |spec|
|
|
20
20
|
# Set 'allowed_push_post' to control where this gem can be published.
|
21
21
|
if spec.respond_to?(:metadata)
|
22
22
|
spec.metadata['allowed_push_host'] = 'https://rubygems.org'
|
23
|
-
|
23
|
+
spec.metadata['rubygems_mfa_required'] = 'true'
|
24
24
|
else
|
25
25
|
raise 'RubyGems 2.0 or newer is required to protect against public gem pushes.'
|
26
26
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-exclaim
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Salsify, Inc
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-11-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -104,7 +104,7 @@ extensions: []
|
|
104
104
|
extra_rdoc_files: []
|
105
105
|
files:
|
106
106
|
- ".circleci/config.yml"
|
107
|
-
- ".github/
|
107
|
+
- ".github/CODEOWNERS"
|
108
108
|
- ".gitignore"
|
109
109
|
- ".overcommit.yml"
|
110
110
|
- ".rspec"
|
@@ -144,7 +144,8 @@ licenses:
|
|
144
144
|
- MIT
|
145
145
|
metadata:
|
146
146
|
allowed_push_host: https://rubygems.org
|
147
|
-
|
147
|
+
rubygems_mfa_required: 'true'
|
148
|
+
post_install_message:
|
148
149
|
rdoc_options: []
|
149
150
|
require_paths:
|
150
151
|
- lib
|
@@ -159,8 +160,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
159
160
|
- !ruby/object:Gem::Version
|
160
161
|
version: '0'
|
161
162
|
requirements: []
|
162
|
-
rubygems_version: 3.
|
163
|
-
signing_key:
|
163
|
+
rubygems_version: 3.3.26
|
164
|
+
signing_key:
|
164
165
|
specification_version: 4
|
165
166
|
summary: Ruby utilities for Exclaim UIs
|
166
167
|
test_files: []
|
@@ -1,29 +0,0 @@
|
|
1
|
-
name: Release
|
2
|
-
|
3
|
-
on:
|
4
|
-
check_suite:
|
5
|
-
types: [completed]
|
6
|
-
|
7
|
-
jobs:
|
8
|
-
release:
|
9
|
-
name: Check and Release New Version
|
10
|
-
runs-on: ubuntu-latest
|
11
|
-
# `github.ref` from the `check_suite` trigger is always the default branch
|
12
|
-
if: format('refs/heads/{0}', github.event.check_suite.head_branch) == github.ref && github.event.check_suite.conclusion == 'success'
|
13
|
-
steps:
|
14
|
-
- name: Checkout Code
|
15
|
-
uses: actions/checkout@v2
|
16
|
-
with:
|
17
|
-
fetch-depth: 2
|
18
|
-
|
19
|
-
- name: Setup Ruby
|
20
|
-
uses: actions/setup-ruby@v1
|
21
|
-
with:
|
22
|
-
ruby-version: 2.6
|
23
|
-
|
24
|
-
- name: Release Gem
|
25
|
-
id: release-gem
|
26
|
-
uses: salsify/action-release-gem@v1.1.0
|
27
|
-
env:
|
28
|
-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
29
|
-
RUBYGEMS_API_KEY: ${{ secrets.RUBYGEMS_API_KEY }}
|