libdolt 0.33.2 → 0.33.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -17,5 +17,5 @@
17
17
  #++
18
18
 
19
19
  module Dolt
20
- VERSION = "0.33.2"
20
+ VERSION = "0.33.3"
21
21
  end
@@ -72,6 +72,17 @@ The content you're attempting to browse appears to be binary.
72
72
  "<pre class=\"#{class_names.join(' ')}\">" +
73
73
  "<ol class=\"linenums gts-lines\">#{lines}</ol></pre>"
74
74
  end
75
+
76
+ def safe_blob_text(blob)
77
+ text = blob.text(nil, defined?(Encoding) ? Encoding.default_external : nil)
78
+
79
+ if text.respond_to?(:encode)
80
+ text = text.encode('UTF-16', :invalid => :replace, :undef => :replace,
81
+ :replace => "�").encode('UTF-8')
82
+ end
83
+
84
+ text
85
+ end
75
86
  end
76
87
  end
77
88
  end
@@ -1 +1 @@
1
- 383216e07edec271936c7fd87b69c346511aedb2
1
+ cd104f8b749c206e7faef1cb7c03f453cbb1aa57
@@ -73,4 +73,13 @@ describe Dolt::View::Blob do
73
73
  assert_match /&lt;hey&gt;/, html
74
74
  end
75
75
  end
76
+
77
+ describe "safe_blob_text" do
78
+ it "returns blob's text with all invalid characters (for string's encoding) replaced with �" do
79
+ repository = Dolt::Git::Repository.new(Dolt.fixture_repo_path)
80
+ blob = repository.blob('master', 'bad-utf.txt')
81
+
82
+ assert_equal "żółć & �.", safe_blob_text(blob)
83
+ end
84
+ end
76
85
  end
data/views/blob.erb CHANGED
@@ -28,6 +28,6 @@
28
28
  <li><a href="<%= raw_url(repository_slug, ref, path) %>">Raw blob</a></li>
29
29
  </ul>
30
30
  <%= breadcrumb(repository_slug, ref, path) %>
31
- <%= format_blob(path, blob.text(nil, defined?(Encoding) ? Encoding.default_external : nil), repository_slug, ref) %>
31
+ <%= format_blob(path, safe_blob_text(blob), repository_slug, ref) %>
32
32
  </div>
33
33
  </div>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: libdolt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.33.2
4
+ version: 0.33.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-09-13 00:00:00.000000000 Z
12
+ date: 2013-09-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rugged
@@ -236,6 +236,7 @@ files:
236
236
  - test/fixtures/dolt-test-repo.git/config
237
237
  - test/fixtures/dolt-test-repo.git/description
238
238
  - test/fixtures/dolt-test-repo.git/info/exclude
239
+ - test/fixtures/dolt-test-repo.git/objects/03/0bc1fa37aac317a5d38fbb4f3a6d22b34c6eba
239
240
  - test/fixtures/dolt-test-repo.git/objects/04/76d88d4c60823927c52f872ff09e7f84fb3549
240
241
  - test/fixtures/dolt-test-repo.git/objects/07/4e4c198421bfc8a1bf9a9c0fc117c4569ba0bd
241
242
  - test/fixtures/dolt-test-repo.git/objects/12/67a0fbd3ec606c20f3f1dca1f53bb9505ba9b5
@@ -264,7 +265,9 @@ files:
264
265
  - test/fixtures/dolt-test-repo.git/objects/c0/35ba24bb3bed31589bc6736ca9b116175eb723
265
266
  - test/fixtures/dolt-test-repo.git/objects/c8/cc83f1a1fc3640fce14ab73d4fa4b22b6211d8
266
267
  - test/fixtures/dolt-test-repo.git/objects/ca/d2309100006f94967cdafe678356b96bb098a5
268
+ - test/fixtures/dolt-test-repo.git/objects/cd/104f8b749c206e7faef1cb7c03f453cbb1aa57
267
269
  - test/fixtures/dolt-test-repo.git/objects/cd/888aef50e3742885630ea4aa8c05f12b5518f4
270
+ - test/fixtures/dolt-test-repo.git/objects/d1/f94fb68cf34f7f121a949e89e09d1a8c1b3825
268
271
  - test/fixtures/dolt-test-repo.git/objects/da/dd1e7ec0c822ba96fcee5d064bea66a7be3d5a
269
272
  - test/fixtures/dolt-test-repo.git/objects/de/dbf2faa4f522716ab727e4325a3d75772e137b
270
273
  - test/fixtures/dolt-test-repo.git/objects/df/d46204a2c44405a2591c2dbc7e73d1a81b5334