Skip to content

Commit abcba4b

Browse files
authored
Merge pull request #1510 from MSP-Greg/00-ruby3.3-bom
Parser::SourceParser#convert_encoding - fixup BOM encoding
2 parents a3b9c37 + fe4f32e commit abcba4b

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

lib/yard/parser/source_parser.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -476,9 +476,8 @@ def convert_encoding(content)
476476
content.force_encoding('binary')
477477
ENCODING_BYTE_ORDER_MARKS.each do |encoding, bom|
478478
bom.force_encoding('binary')
479-
if content[0, bom.size] == bom
480-
content.force_encoding(encoding)
481-
return content
479+
if content.start_with?(bom)
480+
return content.sub(bom, '').force_encoding(encoding)
482481
end
483482
end
484483
content.force_encoding('utf-8') # UTF-8 is default encoding

0 commit comments

Comments
 (0)