wvanbergen/request-log-analyzer — Issue #110: Do not change Encoding.default_external
Author: eregon
Created: 2012-02-25 19:33:11+00:00
State: open

Hello,

The commit https://github.com/wvanbergen/request-log-analyzer/commit/b777252b73f36e486e4a93a756c587b624376f56 seems very wrong to me as it modify global state and may alter other libraries behavior.

If this is a fix for Rails, the problem should be solved in Rails. If it is needed for request-log-analyser itself, it should not be needed and things like 'b' mode should be used instead.

I met this problem today while running alf specs with ruby-trunk.
Let me explain what I did to find out the problem:

* The spec failing was about yaml output, which showed a base64 binary String.
* So I looked at YAML and figured it was somewhere else.
* I figured it's somehow linked to the CSV library (by looking who use String#force_encoding).
* The CSV library might use #force_encoding if the output is binary, which is the case on ruby-trunk now because 1) Encoding.default_external was changed and 2) on ruby-trunk StringIO.read might return a binary string.

That latter behavior might seem weird, but it's actually logical. If you are telling ruby that all external resources (such as CSV files) are binary, the result String should have a binary encoding.

So, could you please remove that global state change?