<html>
<head>
<base href="https://bugs.freedesktop.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - xdg-mime returns wrong mime type on generic DE when filename contains a colon"
href="https://bugs.freedesktop.org/show_bug.cgi?id=106894">106894</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>xdg-mime returns wrong mime type on generic DE when filename contains a colon
</td>
</tr>
<tr>
<th>Product</th>
<td>Portland
</td>
</tr>
<tr>
<th>Version</th>
<td>1.1.0 rc1
</td>
</tr>
<tr>
<th>Hardware</th>
<td>x86-64 (AMD64)
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux (All)
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>medium
</td>
</tr>
<tr>
<th>Component</th>
<td>xdg-utils
</td>
</tr>
<tr>
<th>Assignee</th>
<td>portland-bugs@lists.freedesktop.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>freedesktop@shalmirane.com
</td>
</tr></table>
<p>
<div>
<pre>The info_generic function in xdg-mime looks like this:
info_generic()
{
if mimetype --version >/dev/null 2>&1; then
DEBUG 1 "Running mimetype -b \"$1\""
mimetype -b "$1"
else
DEBUG 1 "Running file --mime-type \"$1\""
/usr/bin/file --mime-type "$1" 2> /dev/null | cut -d ":" -f 2 | sed
s/"^ "//
fi
if [ $? -eq 0 ]; then
exit_success
else
exit_failure_operation_failed
fi
}
The problem occurs if /usr/bin/file is executed and the filename contains the
colon.
Normally file outputs both the filename and the mimetype, but only the mimtype
is desired so cut is employed to split the output from file into two pieces and
return only the second, the mimetype.
I have not spent a lot of time trying to determine the best solution to this
problem. What worked for me was to replace the whole line with:
/usr/bin/file -b --mime-type "$1" 2> /dev/null
The -b option tell file to only output the mimetype and not the filename.</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are the assignee for the bug.</li>
</ul>
</body>
</html>