Instrument usage of bug with iteration of String with offset or 0 limit (#1667)

This commit is contained in:
Dylan Thacker-Smith
2023-01-11 14:05:50 -05:00
committed by GitHub
parent bf711a0521
commit c743936a78
2 changed files with 35 additions and 1 deletions
+5 -1
View File
@@ -16,7 +16,11 @@ module Liquid
# Maintains Ruby 1.8.7 String#each behaviour on 1.9
if collection.is_a?(String)
return collection.empty? ? [] : [collection]
return [] if collection.empty?
if from > 0 || to == 0
Usage.increment("string_slice_bug")
end
return [collection]
end
return [] unless collection.respond_to?(:each)