Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mimemagic
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ikcrm_common
mimemagic
Commits
4a26581f
Commit
4a26581f
authored
Jul 29, 2013
by
Daniel Mendler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix magic matching for 1.9.3
parent
143dd14e
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
9 deletions
+13
-9
.gitignore
+5
-0
lib/mimemagic.rb
+8
-9
No files found.
.gitignore
0 → 100644
View file @
4a26581f
*.swp
*.gem
Gemfile.lock
.bundle
.yardoc
lib/mimemagic.rb
View file @
4a26581f
...
@@ -79,10 +79,11 @@ class MimeMagic
...
@@ -79,10 +79,11 @@ class MimeMagic
mime
=
mime
=
unless
io
.
respond_to?
(
:seek
)
&&
io
.
respond_to?
(
:read
)
unless
io
.
respond_to?
(
:seek
)
&&
io
.
respond_to?
(
:read
)
str
=
io
.
respond_to?
(
:read
)
?
io
.
read
:
io
.
to_s
str
=
io
.
respond_to?
(
:read
)
?
io
.
read
:
io
.
to_s
str
=
str
.
b
if
str
.
respond_to?
:b
str
=
str
.
force_encoding
(
Encoding
::
BINARY
)
if
str
.
respond_to?
:force_encoding
MAGIC
.
find
{
|
type
,
matches
|
magic_match_str
(
str
,
matches
)
}
MAGIC
.
find
{
|
type
,
matches
|
magic_match_str
(
str
,
matches
)
}
else
else
io
.
binmode
io
.
binmode
io
.
set_encoding
(
Encoding
::
BINARY
,
Encoding
::
BINARY
)
if
io
.
respond_to?
(
:set_encoding
)
MAGIC
.
find
{
|
type
,
matches
|
magic_match_io
(
io
,
matches
)
}
MAGIC
.
find
{
|
type
,
matches
|
magic_match_io
(
io
,
matches
)
}
end
end
mime
&&
new
(
mime
[
0
])
mime
&&
new
(
mime
[
0
])
...
@@ -113,29 +114,27 @@ class MimeMagic
...
@@ -113,29 +114,27 @@ class MimeMagic
match
=
match
=
if
Range
===
offset
if
Range
===
offset
io
.
seek
(
offset
.
begin
)
io
.
seek
(
offset
.
begin
)
io
.
read
(
offset
.
end
-
offset
.
begin
+
value
.
length
).
include?
(
value
)
x
=
io
.
read
(
offset
.
end
-
offset
.
begin
+
value
.
bytesize
)
x
&&
x
.
include?
(
value
)
else
else
io
.
seek
(
offset
)
io
.
seek
(
offset
)
io
.
read
(
value
.
length
)
==
value
io
.
read
(
value
.
bytesize
)
==
value
end
end
match
&&
(
!
children
||
magic_match_io
(
io
,
children
))
match
&&
(
!
children
||
magic_match_io
(
io
,
children
))
end
end
rescue
false
end
end
def
self
.
magic_match_str
(
str
,
matches
)
def
self
.
magic_match_str
(
str
,
matches
)
matches
.
any?
do
|
offset
,
value
,
children
|
matches
.
any?
do
|
offset
,
value
,
children
|
match
=
match
=
if
Range
===
offset
if
Range
===
offset
str
[
offset
.
begin
,
offset
.
end
-
offset
.
begin
+
value
.
length
].
include?
(
value
)
x
=
str
[
offset
.
begin
,
offset
.
end
-
offset
.
begin
+
value
.
bytesize
]
x
&&
x
.
include?
(
value
)
else
else
str
[
offset
,
value
.
length
]
==
value
str
[
offset
,
value
.
bytesize
]
==
value
end
end
match
&&
(
!
children
||
magic_match_str
(
str
,
children
))
match
&&
(
!
children
||
magic_match_str
(
str
,
children
))
end
end
rescue
false
end
end
private_class_method
:magic_match_io
,
:magic_match_str
private_class_method
:magic_match_io
,
:magic_match_str
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment