Commit 3f6e44e 1 parent 114cd43 commit 3f6e44e Copy full SHA for 3f6e44e
File tree 4 files changed +7
-31
lines changed
4 files changed +7
-31
lines changed Original file line number Diff line number Diff line change @@ -53,7 +53,6 @@ def parse
53
53
end
54
54
55
55
manifest_files . each do |file |
56
- check_manifest_file_encoding ( file )
57
56
dependency_set += workfile_file_dependencies ( file )
58
57
end
59
58
@@ -83,15 +82,6 @@ def manifest_files
83
82
dependency_files . select { |f | f . type == "file" && f . name . match? ( YAML_REGEXP ) }
84
83
end
85
84
86
- sig { params ( file : Dependabot ::DependencyFile ) . void }
87
- def check_manifest_file_encoding ( file )
88
- return unless file . content &.start_with? ( "\uFEFF " )
89
-
90
- file_path = Pathname . new ( file . directory ) . join ( file . name ) . cleanpath . to_path
91
- msg = "The file appears to have been saved with a byte order mark (BOM). This will prevent proper parsing."
92
- raise Dependabot ::DependencyFileNotParseable . new ( file_path , msg )
93
- end
94
-
95
85
sig { params ( file : Dependabot ::DependencyFile ) . returns ( DependencySet ) }
96
86
def workfile_file_dependencies ( file )
97
87
dependency_set = DependencySet . new
Original file line number Diff line number Diff line change @@ -76,7 +76,13 @@ def yamlfiles
76
76
@yamlfiles ||= T . let (
77
77
repo_contents ( raise_errors : false )
78
78
. select { |f | f . type == "file" && f . name . match? ( YAML_REGEXP ) }
79
- . map { |f | fetch_file_from_host ( f . name ) } ,
79
+ . map do |f |
80
+ fetched = fetch_file_from_host ( f . name )
81
+ # The YAML parser used doesn't properly handle a byte-order-mark (BOM) and it can cause failures in
82
+ # unexpected ways. That BOM is removed here to allow regular updates to proceed.
83
+ fetched . content = T . must ( fetched . content ) [ 1 ..-1 ] if fetched . content &.start_with? ( "\uFEFF " )
84
+ fetched
85
+ end ,
80
86
T . nilable ( T ::Array [ DependencyFile ] )
81
87
)
82
88
end
Original file line number Diff line number Diff line change 1142
1142
end
1143
1143
end
1144
1144
end
1145
-
1146
- context "with an invalid yaml file" do
1147
- let ( :podfile_fixture_name ) { "with_bom.yaml" }
1148
-
1149
- it "throws when the yaml starts with a byte order mark" do
1150
- expect do
1151
- _unused = dependencies
1152
- end . to raise_error ( Dependabot ::DependencyFileNotParseable )
1153
- end
1154
- end
1155
1145
end
1156
1146
1157
1147
describe "YAML parse" do
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments