Skip to content

Fix favicon scraper

Alex Gleason requested to merge alexgleason/pleroma:favicon-fix into develop

The favicon scraper was putting "null" in the database for all favicons. It's because of this failing snippet of code: Pleroma.HTTP.get(to_string(instance_uri), [{:Accept, "text/html"}]) which results in:

** (FunctionClauseError) no function clause matching in String.downcase/2    
    
    The following arguments were given to String.downcase/2:
    
        # 1
        :Accept
    
        # 2
        :default
    
    Attempted function clauses (showing 4 out of 4):
    
        def downcase("", _mode)
        def downcase(string, :default) when is_binary(string)
        def downcase(string, :ascii) when is_binary(string)
        def downcase(string, mode) when mode === :greek
    
    (elixir 1.10.4) lib/string.ex:813: String.downcase/2
    (pleroma 2.1.50-15-g93762eb5-chat-moderation+dev) lib/pleroma/http/request_builder.ex:38: anonymous fn/1 in Pleroma.HTTP.RequestBuilder.headers/2
    (elixir 1.10.4) lib/enum.ex:3305: Enum.find_list/3
    (pleroma 2.1.50-15-g93762eb5-chat-moderation+dev) lib/pleroma/http/request_builder.ex:38: Pleroma.HTTP.RequestBuilder.headers/2
    (pleroma 2.1.50-15-g93762eb5-chat-moderation+dev) lib/pleroma/http/http.ex:95: Pleroma.HTTP.build_request/6
    (pleroma 2.1.50-15-g93762eb5-chat-moderation+dev) lib/pleroma/http/http.ex:69: Pleroma.HTTP.request/5

My solution is to ensure that :Accept gets converted into a string before the check in request_builder.ex.

cc @lanodan

Merge request reports