Bug 211025 - Automatic syntax highlighting in kate not reliable for XML files
Summary: Automatic syntax highlighting in kate not reliable for XML files
Status: RESOLVED FIXED
Alias: None
Product: kate
Classification: Applications
Component: syntax (show other bugs)
Version: unspecified
Platform: Fedora RPMs Linux
: NOR normal
Target Milestone: ---
Assignee: KWrite Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-10-18 23:31 UTC by Steven M. Parrish
Modified: 2010-05-09 19:01 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Steven M. Parrish 2009-10-18 23:31:20 UTC
Version:            (using KDE 4.3.2)
OS:                Linux
Installed from:    Fedora RPMs

Description of problem:
The automatic syntax highlighting in kate is not reliable. Kate should rely on
the content of a file rather than it's extension.

Version-Release number of selected component (if applicable):
kdesdk-4.3.1-1.fc11.x86_64

How reproducible:
always

Steps to Reproduce:
1. $ kate comps-f11.xml.in (taken from
http://cvs.fedoraproject.org/viewvc/comps/comps-f11.xml.in?revision=1.306)

Actual results:
No syntax highlighting, I have to select the markup type manually to get it.

Expected results:
xml should be choosen by default based on the header of the file of it's mime
type.

Additional info:
After renaming the file to comps-f11.xml the highlighting is fine.  

------- Comment #1 From Rex Dieter (rdieter@math.unl.edu) 2009-10-12 10:36:33 EDT (-) [reply] -------

Interesting,

$ xdg-mime query filetype comps-f11.xml.in
application/xml

So the mimetype is recognized properly, kate should indeed use that.  

------- Comment #2 From Christoph Wickert (cwickert@fedoraproject.org) 2009-10-12 10:51:32 EDT (-) [reply] -------

Strange:

$ xdg-mime query filetype comps-f11.xml.in
text/plain

Did you checkup the file or download it? I checked it out.

$ cp comps-f11.xml.in comps-f11.xml
$ xdg-mime query filetype comps-f11.xml
text/xml

So obviously kate uses the extension rather than the mime type. Other programs,
such as geany or gedit correctly select the markup.  

------- Comment #3 From Christoph Wickert (cwickert@fedoraproject.org) 2009-10-12 10:53:42 EDT (-) [reply] -------

Hmmm...

$ wget -q
http://cvs.fedoraproject.org/viewvc/comps/comps-f11.xml.in?revision=1.306
$ xdg-mime query filetype comps-f11.xml.in\?revision\=1.306
text/plain  

------- Comment #4 From Rex Dieter (rdieter@math.unl.edu) 2009-10-12 10:58:42 EDT (-) [reply] -------

Ah, recent fixes to xdg-utils in rawhide may be helping here.

I'm using 
xdg-utils-1.0.2-13.20090928cvs.fc12.noarch
inside a kde session.


If you want to test stuff directly, try
kmimetypefinder comps-f11.xml.in  

------- Comment #5 From Christoph Wickert (cwickert@fedoraproject.org) 2009-10-12 11:10:18 EDT (-) [reply] -------

$ kmimetypefinder comps-f11.xml.in 
application/xml
(accuracy 40)
$ file comps-f11.xml.in 
comps-f11.xml.in: XML  document text  

------- Comment #6 From Kevin Kofler (kevin@tigcc.ticalc.org) 2009-10-12 15:55:25 EDT (-) [reply] -------

Kate just relies on shared-mime-info to detect the mimetype. So whatever
xdg-mime returns is also what Kate will detect. But xdg-mime is also just a
frontend, shared-mime-info contains the actual data.

I'll let the shared-mime-info maintainers decide whether to accept this as a
bug or close it as NOTABUG. Relying on the extension rather than the contents
wherever possible is an intentional feature, it's much faster to detect the
file type from the extension than to open the file and look at what's inside.
So content matching is only used where extensions don't work reliably.

The "file" tool is mainly content-based, but it's obsolescent, shared-mime-info
is what most current software uses. And the decision to rely on extensions more
than on content matching is a deliberate design decision.  

------- Comment #7 From Kevin Kofler (kevin@tigcc.ticalc.org) 2009-10-12 15:57:07 EDT (-) [reply] -------

That said, looking at your differing results, it looks like this is already
fixed in F12's shared-mime-info, isn't it?  

------- Comment #8 From Rex Dieter (rdieter@math.unl.edu) 2009-10-12 16:00:28 EDT (-) [reply] -------

kmimetypefinder is working ok to identify mimetype (see comment #5) so it's
probably not shared-mime-info.

Sho_ in #fedora-kde earlier commented that kate has some internal mime handling
bits, and is probably simply doing the wrong thing here.  

------- Comment #9 From Bastien Nocera (bnocera@redhat.com) 2009-10-12 21:18:59 EDT (-) [reply] -------

If kate opens the file, it should definitely be looking at the mime-type
associated with the data, rather than just the filename if it returns
text/plain.

I tested shared-mime-info, and it returns application/xml for the comps.xml.in
file as expected for both file data, and using the actual file. Filename fails
as expected.

Reassigning to kdesdk, I don't know in which package kate is.

Steven, unless you suddenly became shared-mime-info maintainer, don't set the
bug status to assigned...  

------- Comment #10 From Kevin Kofler (kevin@tigcc.ticalc.org) 2009-10-12 22:37:21 EDT (-) [reply] -------

Kate resides in kdesdk, so that's OK. (The actual fault may be in the KatePart
in kdelibs, but that's our problem to sort out anyway. :-) )

Steven M. Parrish is a triager (the KDE triager), he was just following the
bizarre Fedora convention of using ASSIGNED as "confirmed". (We're shoehorning
our workflow into the states in this Bugzilla which are designed for RHEL.)  

------- Comment #11 From Christoph Wickert (cwickert@fedoraproject.org) 2009-10-13 04:52:19 EDT (-) [reply] -------

(In reply to comment #9)
> I tested shared-mime-info, and it returns application/xml for the comps.xml.in
> file as expected for both file data, and using the actual file.

For me xdg-mime returns text/plain but not text/xml. Please note that this bug
was filed against F11 and not rawhide.  

------- Comment #12 From Bastien Nocera (bnocera@redhat.com) 2009-10-13 07:54:14 EDT (-) [reply] -------

xdg-mime is a pile of crap and will use different ways of determining the
mime-type depending on the desktop environment.

It will use gnome-vfs under GNOME, kfile under KDE, and "file -i" under others.

I tested using the mime test suite in shared-mime-info, using the latest
xdgmime git master. I don't believe we changed anything related to XML
mime-types in the last few releases.  

------- Comment #13 From Kevin Kofler (kevin@tigcc.ticalc.org) 2009-10-13 08:55:38 EDT (-) [reply] -------

Well, if gnome-vfs and kfile return different things, that's a bug in either of
them, as they both use shared-mime-info.  

------- Comment #14 From Bastien Nocera (bnocera@redhat.com) 2009-10-13 09:17:14 EDT (-) [reply] -------

Except that gnome-vfs (and gvfs) use the upstream xdgmime reference
implementation, and kfile uses a KDE specific implementation, even though they
use the same data.  

------- Comment #15 From Rex Dieter (rdieter@math.unl.edu) 2009-10-13 09:22:29 EDT (-) [reply] -------

kmimetypefinder (comment #5) is fine.    kfile is from kde3.

Work to improve/fix kde4 integration in xdg-utils is ongoing (current versions
do indeed use kmimetypefinder on kde4 correctly).  So, for < F-12 on kde4,
xdg-mime isn't working, granted.

Now, Sorry I didn't help properly triage this on my previous comments.

From the looks of it, addressing this may be non-trivial (comment #8), so I
think the best way forward is to report this bug to kde upstream, bugs.kde.org.
Comment 1 Rex Dieter 2009-12-02 14:47:21 UTC
confirming behavior using kde-4.3.3
Comment 2 Christoph Cullmann 2010-05-09 19:00:05 UTC
No error at all, just the author of the xml hl didn't add application/xml to the list of supported mime-types ;) (but *.xml)
Comment 3 Christoph Cullmann 2010-05-09 19:01:17 UTC
SVN commit 1124610 by cullmann:

add application/xml to mime-type list for xml hl
BUG: 211025


 M  +1 -1      xml.xml  


WebSVN link: http://websvn.kde.org/?view=rev&revision=1124610