How to stop file type changing automatically

marc gmane at auxbuss.com
Mon Aug 14 20:39:20 UTC 2006


Roshan Mansinghani said...
> On 8/14/06, marc <gmane at auxbuss.com> wrote:
> >
> > Roshan Mansinghani said...
> > > On 8/13/06, marc <gmane at auxbuss.com> wrote:
> > > >
> > > > Heyho,
> > > >
> > > > My config file for gvim has been given the .html file type. This
> > results
> > > > in it being opened by Firefox, when opened via a file manager. Not
> > what
> > > > I want.
> > > >
> > > > Taking a closer look, this behaviour occurs when the file contain a
> > > > <script> entry. In other words, the file happily lives life as a text
> > > > file type until an edit is saved containing the text "<script>", when
> > > > it, immediately and without notification, automatically changes its
> > file
> > > > type to .html
> > > >
> > > > How do I stop this from happening?
> > > >
> > > > It reminds me of Microsoft's Clippy - but rather worse - because it
> > > > doesn't tell me it's doing it, and it and doesn't give me the option
> > top
> > > > stop it.
> > > >
> > > > For now, I've added a filename patterns to text/plain of .*, which
> > might
> > > > well be sufficient.
> > > >
> > > > It also begs the question of when and where this changing is done.
> > > > Frankly, I can't conceive of a time when I'd want this behaviour.
> >
> > > Does this happen only in gvim or if you use another editor (say, Kate)
> > do
> > > you have the same problem?
> >
> > Oh, it's not the editor. I can copy my (now protected) .gvimrc to
> > another directory and, as soon as I rename it to gvimrc it "becomes" an
> > HTML mime type. If I then rename it to gvimrc.txt, then it becomes a
> > text/plain type again.
> >
> > Try it. Create an empty text file called fred. Add some text and it will
> > behave as a regular text file. Now, add the lines:
> >
> > <script>
> > <script>
> >
> > save it, and it's changed to an HTML file type. You can use any editor
> > to do this. (If you only use one line containing <script>, then the type
> > doesn't change. It knows what it's looking for :-) )
> >
> > I thought that it might be associated with Desktop/Behaviour/File
> > icons/Show icon previews, but I switched them off for text and HTML
> > files and it still happens.
> >
> > What is parsing files to cause this? I want it to stop!
> >
> 
> I have reproduced what you are talking about.

Yup, it's pretty obvious, isn't it.

> First, the file is not actually being changed or renamed to a .html
> extension.

I didn't say it was. I said its mime/file type was being changed, and 
that it is. Oh yes.

> The only thing that is happening is that Konqueror is guessing that
> this is an html file and giving you options corresponding with its guess.

Who said I was using Konqueror? Not me.

> So, the question is, do we have a way to tweak konqueror so that it
> doesn't "guess" the filetype by parsing the file and instead only
> assigns MIME types based on extensions.

Well, if was only Konqueror, that may be. But it isn't.

Frankly, I don't want the files being parsed at all, and certainly not 
so that a piece of software can randomly change its mime type. 

> One option you have is to use file extensions when you name things, then set
> up konqueror to some default behavior when it encounters files with that
> extension.

That's not a viable option, though. The case in point disproves it.

> But, if this file is a config file for gvim, perhaps you don't
> have the option of renaming it in anyway.

There ya go.

> Again, some research needs to be done that clarifies if this feature
> of konqueror can be turned off.

As I mentioned, it's not just Konqueror.

Seems to me that a dev dreamed up what he thought was something 
clever/neat and it's really, well, it's pretty darn stupid if you ask 
me. How it made production is rather worrying.

The worst part of it all is that KDE has a configuration panel for 
precisely this action - something the user can control. In this case, it 
can't be overridden. That's very bad.

In the absence of understanding what is happening here, I consider this 
a security risk.

Say that I have a file of confidential information that is processed in 
some way based on its mime type - it could just be launching an editor. 
I click the file and Johnny Mimechange's code leaps in to action, 
changes the mime type and activates a function that emails the file to, 
say, everyone in my address book. Why not? I've associated a mime type 
to do that on a file.

Yes I understand that this is very unlikely, but the potential is there 
for it to happen and that is sufficient.

I hope we can get to the bottom of this quickly.

-- 
Best,
Marc





More information about the kubuntu-users mailing list