https://www.redmine.org/https://www.redmine.org/favicon.ico?16793021292012-04-03T08:27:03ZRedmineRedmine - Defect #10590: WikiContent::Version#text return string with #<Encoding:ASCII-8BIT> when uncompressedhttps://www.redmine.org/issues/10590?journal_id=371722012-04-03T08:27:03ZToshi MARUYAMA
<ul><li><strong>Assignee</strong> deleted (<del><i>Toshi MARUYAMA</i></del>)</li></ul><p>What database do you use?<br />mysql1 has problems on Ruby1.9.<br />You need to use mysql2 instead of mysql1.<br /><a class="source" href="https://www.redmine.org/projects/redmine/repository/svn/revisions/9244/entry/trunk/Gemfile#L44">source:trunk/Gemfile@9244#L44</a></p> Redmine - Defect #10590: WikiContent::Version#text return string with #<Encoding:ASCII-8BIT> when uncompressedhttps://www.redmine.org/issues/10590?journal_id=371732012-04-03T08:31:50ZToshi MARUYAMA
<ul></ul><p>Sorry, in description "postgresql 8.4.11".</p> Redmine - Defect #10590: WikiContent::Version#text return string with #<Encoding:ASCII-8BIT> when uncompressedhttps://www.redmine.org/issues/10590?journal_id=371742012-04-03T08:38:53ZAlexander Oryol
<ul></ul><p>Patch is (in attachment):<br /><pre><code class="diff syntaxhl"><span class="p">commit b0ec4111730809bc2f4bafd071ba2271e290e9e1
Author: Alex Eagle <eagle.alex@gmail.com>
Date: Tue Apr 3 11:58:05 2012 +0400
</span>
Force encoding string from data binary always (not only compressed)
diff --git a/app/models/wiki_content.rb b/app/models/wiki_content.rb
<span class="gh">index 430e9a5..d5a3870 100644
</span><span class="gd">--- a/app/models/wiki_content.rb
</span><span class="gi">+++ b/app/models/wiki_content.rb
</span><span class="p">@@ -91,14 +91,16 @@</span> class WikiContent < ActiveRecord::Base
end
def text
<span class="gd">- @text ||= case compression
- when 'gzip'
- str = Zlib::Inflate.inflate(data)
</span><span class="gi">+ @text ||= begin
+ str = case compression
+ when 'gzip'
+ Zlib::Inflate.inflate(data)
+ else
+ # uncompressed data
+ data
+ end
</span> str.force_encoding("UTF-8") if str.respond_to?(:force_encoding)
str
<span class="gd">- else
- # uncompressed data
- data
</span> end
end
</code></pre></p> Redmine - Defect #10590: WikiContent::Version#text return string with #<Encoding:ASCII-8BIT> when uncompressedhttps://www.redmine.org/issues/10590?journal_id=371752012-04-03T08:58:19ZToshi MARUYAMA
<ul></ul><p>It seems acts_as_versioned or PostgreSQL problem.</p> Redmine - Defect #10590: WikiContent::Version#text return string with #<Encoding:ASCII-8BIT> when uncompressedhttps://www.redmine.org/issues/10590?journal_id=371762012-04-03T09:08:57ZAlexander Oryol
<ul></ul><p>Not PostgreSQL exactly.<br />DB return byte-array. Rails interpretate column (t.column :data, :binary) in string context as ASCII-8BIT unless otherwise.<br />Соde for transformation field 'data' into text defined in WikiContent::Version#text.<br />IMHO, this is model Version problem.</p> Redmine - Defect #10590: WikiContent::Version#text return string with #<Encoding:ASCII-8BIT> when uncompressedhttps://www.redmine.org/issues/10590?journal_id=371772012-04-03T09:29:18ZEtienne Massip
<ul></ul><p>Might be tied to <a class="issue tracker-1 status-5 priority-4 priority-default closed" title="Defect: Unable to export wiki page to text/html file (Closed)" href="https://www.redmine.org/issues/6941">#6941</a>; I just saw I had this old issue back and that upgrading <code>pg</code> gem to latest version in <code>Gemfile</code> (+<code>bundle update</code>) solved it.</p> Redmine - Defect #10590: WikiContent::Version#text return string with #<Encoding:ASCII-8BIT> when uncompressedhttps://www.redmine.org/issues/10590?journal_id=371782012-04-03T09:49:54ZAlexander Oryol
<ul></ul><p>Updated pg gem to pg (0.13.2) do not solve it.</p>
<pre>
$ cat Gemfile|grep pg
gem "pg"#, "~> 0.9.0"
$ cat Gemfile.lock|grep pg
pg (0.13.2)
pg
</pre>
<p>Result:</p>
<pre>
>> WikiPage.first.content.versions.last.data.encoding
=> #<Encoding:ASCII-8BIT>
</pre> Redmine - Defect #10590: WikiContent::Version#text return string with #<Encoding:ASCII-8BIT> when uncompressedhttps://www.redmine.org/issues/10590?journal_id=371922012-04-03T13:21:56ZEtienne Massip
<ul><li><strong>Tracker</strong> changed from <i>Patch</i> to <i>Defect</i></li><li><strong>Target version</strong> set to <i>1.4.0</i></li><li><strong>Affected version (unused)</strong> set to <i>devel</i></li></ul><p>Potential release blocker.</p>
<p>Aside note: as explained above, required <code>pg</code> gem version should be raised to prevent <a class="issue tracker-1 status-5 priority-4 priority-default closed" title="Defect: Unable to export wiki page to text/html file (Closed)" href="https://www.redmine.org/issues/6941">#6941</a>.</p> Redmine - Defect #10590: WikiContent::Version#text return string with #<Encoding:ASCII-8BIT> when uncompressedhttps://www.redmine.org/issues/10590?journal_id=372012012-04-03T17:50:41ZEtienne Massip
<ul><li><strong>Status</strong> changed from <i>New</i> to <i>Confirmed</i></li></ul> Redmine - Defect #10590: WikiContent::Version#text return string with #<Encoding:ASCII-8BIT> when uncompressedhttps://www.redmine.org/issues/10590?journal_id=372412012-04-06T07:22:04ZJean-Philippe Langjp_lang@yahoo.fr
<ul><li><strong>Status</strong> changed from <i>Confirmed</i> to <i>Closed</i></li><li><strong>Resolution</strong> set to <i>Fixed</i></li></ul><p>Patch applied in <a class="changeset" title="WikiContent::Version#text may return ascii-8bit encoded string (#10590)." href="https://www.redmine.org/projects/redmine/repository/svn/revisions/9329">r9329</a>.</p>