Package: firefox
Version: 1.5.dfsg-4
Severity: wishlist
Tags: patch

I've written a simple /usr/share/bug/firefox/script to include in new
reportbug reports the names and versions of installed extensions.  It
may not yet be acceptable for inclusion into the pacakge, but I've
tested it against some (exhaustive?) Debian packages, and the output
is what I intend, sane, and seems to have useful content.  It is still
not clear to me what directories need to be seached; it may well be
that /u/l/m-f and /u/s/f aren't ever used by firefox for loading
extensions.

I don't know the best way of accessing ~/.mozilla/; best would be
something that doesn't assume certain variables are set, doesn't
assume it is under /home/, and doesn't require parsing the output of
getent or whatever.

I've also written a libxml thingy in C, which actually parses the html
.. presumably there is some tool that makes this unnecessary, but I
was bored, and was able to borrow from a pre-existing work.

#! /bin/sh
set -e;

dirs="/usr/lib/firefox
        /usr/lib/mozilla-firefox
        /usr/share/firefox
        /usr/share/mozilla-extensions
        $HOME/.mozilla/
        ";

exec 1>&3;

for f in `find $dirs -name install.rdf`;
do
        echo "$f:"
        for g in name version;
        do
                echo `grep "em:$g" "$f"`;
        done;
        echo;
done;

Here's the output it generates for the given extensions:

firefox
/usr/lib/firefox/extensions/{972ce4c6-7e08-4474-a285-3208198ce6fd}/install.rdf:
<em:name>Firefox (default)</em:name>
<em:version>2.0</em:version>

firefox-dom-inspector
/usr/lib/firefox/extensions/[EMAIL PROTECTED]/install.rdf:
<em:name>DOM Inspector</em:name>
<em:version>1.8.0.1</em:version>

firefox-locale-ca
/usr/lib/firefox/extensions/[EMAIL PROTECTED]/install.rdf:
em:name="Catal?? Language Pack"
em:version="1.5"

firefox-locale-eu
/usr/lib/firefox/extensions/[EMAIL PROTECTED]/install.rdf:
em:name="Basque Language Pack"
em:version="1.5"

firefox-webdeveloper
/usr/lib/firefox/extensions/{c45c406e-ab73-11d8-be73-000a95be3b12}/install.rdf:
<em:name>Web Developer</em:name>
<em:version>1.0.2</em:version>

mozilla-stumbleupon
/usr/lib/mozilla-firefox/extensions/{AE93811A-5C9A-4d34-8462-F7B864FC4696}/install.rdf:
<em:name>StumbleUpon</em:name>
<em:version>1.9995</em:version>

mozilla-tabextensions
/usr/share/mozilla-extensions/tabextensions/install.rdf:
<em:name>Tabbrowser Extensions</em:name>
<em:version>2.1.2006012001</em:version>

mozilla-venkman
/usr/share/mozilla-extensions/venkman/install.rdf:
<em:name>JavaScript Debugger</em:name>
<em:version>0.9.85</em:version>

mozilla-nukeimage
/usr/share/mozilla-extensions/nukeimage/install.rdf:
<em:name>Nuke Image</em:name>
<em:version>0.3</em:version>

mozilla-biofox
/usr/share/mozilla-extensions/biofox/install.rdf:
<em:name>bioFOX</em:name>
<em:version>1.1.2</em:version>

mozilla-bookmarksftp
/usr/share/mozilla-extensions/bookmarksftp/install.rdf:
<em:name>Bookmarks Synchronizer</em:name>
<em:version>1.0.2</em:version>

mozilla-checky
/usr/share/mozilla-extensions/checky/install.rdf:
<em:name>Checky</em:name>
<em:version>2.5</em:version>

mozilla-ctxextensions
/usr/share/mozilla-extensions/ctxextensions/install.rdf:
<em:name>ContextMenu Extensions</em:name>
<em:version>4.0.2006011301</em:version>

mozilla-diggler
/usr/share/mozilla-extensions/diggler/install.rdf:
<em:name>Diggler</em:name>
<em:version>0.9</em:version>

mozilla-imagezoom
/usr/share/mozilla-extensions/imagezoom/install.rdf:
<em:name>Image Zoom</em:name>
<em:version>0.2.3</em:version>

mozilla-livehttpheaders
/usr/share/mozilla-extensions/livehttpheaders/install.rdf:
<em:name>Live HTTP Headers</em:name>
<em:version>0.12</em:version>

mozilla-mozgest
/usr/lib/mozilla-firefox/extensions/{FFA36170-80B1-4535-B0E3-A4569E497DD0}/install.rdf:
<em:name>Mouse Gestures</em:name>
<em:version>1.0</em:version>
#if 0
rdfparse.c
Parse RDF files (at least those from firefox)

Copyright (C) 2005-2006 Justin Pryzby <[EMAIL PROTECTED]>

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

make LDLIBS=-lxml2 CPPFLAGS=-I/usr/include/libxml2 CFLAGS='-O3 -g -Wall' rdfparse
#endif

#include <stdlib.h>
#include <libxml/parser.h>

static xmlNodePtr advance(xmlNodePtr cur, char *name)
{
	cur=cur->xmlChildrenNode;
	for ( ; cur && xmlStrcmp(cur->name, (xmlChar *) name); cur=cur->next);
	return cur;
}

int main(int argc, char **argv)
{
	char fail_parse[]="failed to parse XML document";
	char *fn;
	xmlChar *names, *versions;
	xmlDocPtr doc;
	xmlNodePtr cur, name, version;

	if (argc!=2 || NULL==(fn=argv[1])) {
		fprintf(stderr, "requires exactly 1 argument\n");
		exit(EXIT_FAILURE);
	} else if (NULL==(doc=xmlParseFile(fn))) {
		fprintf(stderr, "%s: %s: %d\n", fail_parse, fn, __LINE__);
		exit(EXIT_FAILURE);
	} else if (NULL==(cur=xmlDocGetRootElement(doc))) {
		fprintf(stderr, "%s: %s: %d\n", fail_parse, fn, __LINE__);
		exit(EXIT_FAILURE);
	} else if (xmlStrcmp(cur->name, (xmlChar *)"RDF")) {
		fprintf(stderr, "%s: %s: %d\n", fail_parse, fn, __LINE__);
		exit(EXIT_FAILURE);
	} else if (NULL==(cur=advance(cur, "Description"))) {
		fprintf(stderr, "%s: %s: %d\n", fail_parse, fn, __LINE__);
		exit(EXIT_FAILURE);
	} else if (NULL==(name=advance(cur, "name"))) {
		fprintf(stderr, "%s: %s: %d\n", fail_parse, fn, __LINE__);
		exit(EXIT_FAILURE);
	} else if (NULL==(version=advance(cur, "version"))) {
		fprintf(stderr, "%s: %s: %d\n", fail_parse, fn, __LINE__);
		exit(EXIT_FAILURE);
	} else if (NULL==(names=xmlNodeListGetString(doc, name->xmlChildrenNode, 1))) {
		fprintf(stderr, "%s: %s: %d\n", fail_parse, fn, __LINE__);
		exit(EXIT_FAILURE);
	} else if (NULL==(versions=xmlNodeListGetString(doc, version->xmlChildrenNode, 1))) {
		fprintf(stderr, "%s: %s: %d\n", fail_parse, fn, __LINE__);
		exit(EXIT_FAILURE);
	}

	printf("%s %s\n", names, versions);

	xmlFreeDoc(doc);
	xmlCleanupParser();
	free(names);
	free(versions);
	return 0;
}

Reply via email to