Skip to content

Commit 41f12dd

Browse files
authored
Merge branch 'main' into freeze_concatenated_strings
2 parents fba909e + 068f673 commit 41f12dd

File tree

4 files changed

+56
-9
lines changed

4 files changed

+56
-9
lines changed

.github/dependabot.yml

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "github-actions"
4+
directory: "/"
5+
schedule:
6+
interval: "weekly"

.github/workflows/codeql-analysis.yml

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: "CodeQL"
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
pull_request:
7+
# The branches below must be a subset of the branches above
8+
branches: [ "main" ]
9+
schedule:
10+
- cron: '41 19 * * 2'
11+
12+
jobs:
13+
analyze:
14+
name: Analyze
15+
runs-on: ubuntu-latest
16+
permissions:
17+
actions: read
18+
contents: read
19+
security-events: write
20+
21+
strategy:
22+
fail-fast: false
23+
matrix:
24+
language: [ 'ruby' ]
25+
26+
steps:
27+
- name: Checkout repository
28+
uses: actions/checkout@v3
29+
30+
# Initializes the CodeQL tools for scanning.
31+
- name: Initialize CodeQL
32+
uses: github/codeql-action/init@v2
33+
with:
34+
languages: ${{ matrix.language }}
35+
36+
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
37+
# If this step fails, then you should remove it and run the build manually (see below)
38+
- name: Autobuild
39+
uses: github/codeql-action/autobuild@v2
40+
41+
- name: Perform CodeQL Analysis
42+
uses: github/codeql-action/analyze@v2

lib/addressable/uri.rb

+3-9
Original file line numberDiff line numberDiff line change
@@ -474,19 +474,13 @@ def self.unencode(uri, return_type=String, leave_encoded='')
474474
"Expected Class (String or Addressable::URI), " +
475475
"got #{return_type.inspect}"
476476
end
477-
uri = uri.dup
478-
# Seriously, only use UTF-8. I'm really not kidding!
479-
uri.force_encoding("utf-8")
480477

481-
unless leave_encoded.empty?
482-
leave_encoded = leave_encoded.dup.force_encoding("utf-8")
483-
end
484-
485-
result = uri.gsub(/%[0-9a-f]{2}/iu) do |sequence|
478+
result = uri.gsub(/%[0-9a-f]{2}/i) do |sequence|
486479
c = sequence[1..3].to_i(16).chr
487-
c.force_encoding("utf-8")
480+
c.force_encoding(sequence.encoding)
488481
leave_encoded.include?(c) ? sequence : c
489482
end
483+
490484
result.force_encoding("utf-8")
491485
if return_type == String
492486
return result

spec/addressable/uri_spec.rb

+5
Original file line numberDiff line numberDiff line change
@@ -5992,6 +5992,11 @@ def to_str
59925992
expect(Addressable::URI.unencode_component("ski=%BA%DAɫ")).to eq("ski=\xBA\xDAɫ")
59935993
end
59945994

5995+
it "should not fail with UTF-8 incompatible string" do
5996+
url = "/M%E9/\xE9?p=\xFC".b
5997+
expect(Addressable::URI.unencode_component(url)).to eq("/M\xE9/\xE9?p=\xFC")
5998+
end
5999+
59956000
it "should result in correct percent encoded sequence as a URI" do
59966001
expect(Addressable::URI.unencode(
59976002
"/path?g%C3%BCnther", ::Addressable::URI

0 commit comments

Comments
 (0)