Skip to content

Commit

Permalink
Prevent expanded paths from getting into the history cache
Browse files Browse the repository at this point in the history
Currently dependencies are mutated after they're pulled out of the cache. These same dependencies can then be re-stored later

```
cache.set(key, history.unshift(deps).take(limit))
```

This makes it possible for a project to load the wrong asset.
  • Loading branch information
wlipa authored and schneems committed Sep 25, 2015
1 parent f3d61a3 commit d80c07a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/sprockets/loader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -308,8 +308,10 @@ def fetch_asset_from_dependency_cache(unloaded, limit = 3)

history = cache.get(key) || []
history.each_with_index do |deps, index|
deps.map! { |path| path.start_with?("file-digest://") ? expand_from_root(path) : path }
if asset = yield(deps)
expanded_deps = deps.map do |path|
path.start_with?("file-digest://") ? expand_from_root(path) : path
end
if asset = yield(expanded_deps)
cache.set(key, history.rotate!(index)) if index > 0
return asset
end
Expand Down

0 comments on commit d80c07a

Please sign in to comment.