berns 3.2.1 → 3.3.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: 74e861ab5e3bfb8359f063dc7637b4f9c8f30ed60722b3f6cfec7aaf432915af
4
- data.tar.gz: 17e884c022d55c44ad4ff080ec485d82688664529aee4d656b95d1d93a129e31
3
+ metadata.gz: e477eaf0fc69e3218e9bd93d0ece7a2635b42157dfa4dac49f44134822f5347e
4
+ data.tar.gz: d536572a3ecfb3fb84eac0a5624fb2fb662079de615c0afd431dffe940c064f1
5
5
  SHA512:
6
- metadata.gz: 17166b6a903fba75f3cf3984710735e92206892eec6310bb2144ff5e088694089326426baf2c8e7c1246e681d4887559f01f7364635bfc29006878a908b9912f
7
- data.tar.gz: 9472135003033d1fdc6db413e44cf7ab69be6fa947b9e2a452d2bd24f316f0708055d03d6157adf292c5b9644d73dd08cad261c1b4c45588be18b8069e5366e2
6
+ metadata.gz: 43620249a6d836dca7da50946bf63835b5d21cadcd2fc0de543be5adb11ac4d0f97ee086f139cb49ed600d09b93ba262414f2f7d9113cabd6b50a85a597ea619
7
+ data.tar.gz: 6354871cfe7c0e1558de95f0c5230d3e9edeeed778868496192da8583b747411d08bd16826faa2d53c67e65f0c6216c1c48a751e4abb17d74623351c6c33ead4
data/LICENSE.txt CHANGED
@@ -1,21 +1,20 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2018 Taylor Beck
3
+ Copyright © 2021 Taylor Beck and Evan Lecklider
4
4
 
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the Software), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
11
 
12
- The above copyright notice and this permission notice shall be included in
13
- all copies or substantial portions of the Software.
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
14
 
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- THE SOFTWARE.
15
+ THE SOFTWARE IS PROVIDED AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/ext/berns/berns.c CHANGED
@@ -110,17 +110,24 @@ static VALUE external_sanitize(RB_UNUSED_VAR(VALUE self), VALUE string) {
110
110
  char *str = RSTRING_PTR(string);
111
111
 
112
112
  char dest[slen + 1];
113
- int index = 0;
114
- int open = 0;
115
- int opened = 0;
113
+
114
+ unsigned int index = 0;
115
+ unsigned int open = 0;
116
+ unsigned int modified = 0;
117
+ unsigned int entity = 0;
116
118
 
117
119
  for (unsigned int i = 0; i < slen; i++) {
118
120
  if (str[i] == '<') {
119
121
  open = 1;
120
- opened = 1;
122
+ modified = 1;
121
123
  } else if (str[i] == '>') {
122
124
  open = 0;
123
- } else if (!open) {
125
+ } else if (str[i] == '&') {
126
+ entity = 1;
127
+ modified = 1;
128
+ } else if (str[i] == ';') {
129
+ entity = 0;
130
+ } else if (!open && !entity) {
124
131
  dest[index++] = str[i];
125
132
  }
126
133
  }
@@ -128,10 +135,10 @@ static VALUE external_sanitize(RB_UNUSED_VAR(VALUE self), VALUE string) {
128
135
  dest[index] = '\0';
129
136
 
130
137
  /*
131
- * If a tag was never opened, return the original string, otherwise create a new
132
- * string from our destination buffer.
138
+ * If the string was never modified, return the original string, otherwise
139
+ * create a new string from our destination buffer.
133
140
  */
134
- if (opened) {
141
+ if (modified) {
135
142
  return rb_utf8_str_new_cstr(dest);
136
143
  } else {
137
144
  return string;
data/lib/berns/berns.so CHANGED
Binary file
data/lib/berns/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Berns
3
- VERSION = '3.2.1'
3
+ VERSION = '3.3.0'
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: berns
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.1
4
+ version: 3.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Taylor Beck
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2021-06-15 00:00:00.000000000 Z
12
+ date: 2021-07-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: benchmark-ips