ronin-support 1.0.6 → 1.0.7

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: 04b9f7e7aa3d25c5742621faaeba6ce51150d3959d82867d41901c7cd1a2af06
4
- data.tar.gz: 4e081a47953f762edca8e267c6a31fc168cf8a91f93ce464f7586a1d3e81b2dc
3
+ metadata.gz: 780803451e208e445bd91de1151b5eb486f0cd0ff1b43a683b0a84af631bbeae
4
+ data.tar.gz: 2c9fdafcb627bd9dface2d37aaf980a087642d94ea3c33807917c38c0ce174ff
5
5
  SHA512:
6
- metadata.gz: 5611fdbe096f30f8ad9a4d828b722c221e90b93a9e217e6fb9c3ca3eb54dc7103cb0d39e7b5b98f5a74192c6339adedad97c5c11f69bb5019b2ebc7ca0ef3b03
7
- data.tar.gz: 107956428d0b34d47378c338143e70820cee6a62fedf24927157d5f06f16b4b978957fb02f945f7eabb75e897dc81a2ab58665fbcf56b072a7f7ad4493bb116a
6
+ metadata.gz: 666cffd23c7725aa75d02d89ddeb14ad7e7f1ae012758f9dc14031f5c3bf147a61921dd25b870be45b680abb1a24b9bba4ae5f78957459762a8cd77f97153bdd
7
+ data.tar.gz: 88713bb5dc755570e73a4466a055953adf30979c3a3d83f6d829b780a398655101cdd88ebbf7639691d159640c4cd13554df23368f9d881cfc62e55b96ebf6f8
data/ChangeLog.md CHANGED
@@ -1,3 +1,12 @@
1
+ ### 1.0.7 / 2024-07-13
2
+
3
+ * Improved the performance of {Ronin::Support::Encoding::JS.unescape} and
4
+ {String#js_unescape} by 2x.
5
+ * Correctly parse Unicode surrogate character pairs in JavaScript
6
+ strings (ex: `"\uD83D\uDE80"`) in {Ronin::Support::Encoding::JS.unescape},
7
+ {String#js_unescape}, {Ronin::Support::Encoding::JS.unquote}, and
8
+ {String#js_unquote}.
9
+
1
10
  ### 1.0.6 / 2024-06-19
2
11
 
3
12
  * Fixed error messages in {Ronin::Support::Encoding::Base64.encode} and
@@ -183,16 +183,22 @@ module Ronin
183
183
  #
184
184
  def self.unescape(data)
185
185
  unescaped = String.new(encoding: Encoding::UTF_8)
186
+ scanner = StringScanner.new(data)
186
187
 
187
- data.scan(/[\\%]u[0-9a-fA-F]{1,4}|[\\%][0-9a-fA-F]{1,2}|\\[btnfr\'\"\\]|./) do |c|
188
- unescaped << BACKSLASHED_CHARS.fetch(c) do
189
- if (c.start_with?("\\u") || c.start_with?("%u"))
190
- c[2..].to_i(16)
191
- elsif (c.start_with?("\\") || c.start_with?("%"))
192
- c[1..].to_i(16)
193
- else
194
- c
195
- end
188
+ until scanner.eos?
189
+ unescaped << if (backslash_escape = scanner.scan(/\\[btnfr'"\\]/))
190
+ BACKSLASHED_CHARS[backslash_escape]
191
+ elsif (surrogate_pair = scanner.scan(/\\u[dD][890abAB][0-9a-fA-F]{2}\\u[dD][cdefCDEF][0-9a-fA-F]{2}/))
192
+ hi = surrogate_pair[2..6].to_i(16)
193
+ lo = surrogate_pair[8..12].to_i(16)
194
+
195
+ (0x1_0000 + ((hi - 0xd800) * 0x400) + (lo - 0xdc00))
196
+ elsif (unicode_escape = scanner.scan(/[\\%]u[0-9a-fA-F]{1,4}/))
197
+ unicode_escape[2..].to_i(16)
198
+ elsif (hex_escape = scanner.scan(/[\\%][0-9a-fA-F]{1,2}/))
199
+ hex_escape[1..].to_i(16)
200
+ else
201
+ scanner.getch
196
202
  end
197
203
  end
198
204
 
@@ -19,6 +19,6 @@
19
19
  module Ronin
20
20
  module Support
21
21
  # ronin-support version
22
- VERSION = '1.0.6'
22
+ VERSION = '1.0.7'
23
23
  end
24
24
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ronin-support
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.6
4
+ version: 1.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Postmodern
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-06-20 00:00:00.000000000 Z
11
+ date: 2024-07-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: chars