view a file inside a zip/jar/xpi

Talk about add-ons and extension development.
Post Reply
bijugc
Posts: 399
Joined: March 18th, 2003, 9:52 pm
Contact:

view a file inside a zip/jar/xpi

Post by bijugc »

This is new to me,

Using mozilla/firefox we can view a file inside a zip/jar/xpi

zip/jar/xpi may be at http://, file://, resource://
(i have not tried ftp:// but I belive that too)
Try
<a href="jar:http://mirror.meisterwerk.net/rmozdev/links/WebLinks.xpi!/install.js"> jar:http://mirror.meisterwerk.net/rmozdev/links/WebLinks.xpi!/install.js </a>


resource:// on Firefox:
jar:resource:///chrome/browser.jar!/content/browser/about.png
jar:resource:///chrome/browser.jar!/content/browser/browser.js

resource:// on Mozilla
jar:resource:///chrome/modern.jar!/skin/modern/communicator/button.css


we can even do
<a href="jar:jar:http://mirror.meisterwerk.net/rmozdev/links/WebLinks.xpi!/WebLinks.jar!/content/weblinks/macroeditor.js"> jar:jar:http://mirror.meisterwerk.net/rmozdev/links/WebLinks.xpi!/WebLinks.jar!/content/weblinks/macroeditor.js</a>

yeah, read from a zip file inside another zip file.


XMLHttpRequest can also handle this

Code: Select all

function readfileinjar(url,path) 
{
 var p = new XMLHttpRequest();
 var path2 = path;
 if(path2.substr(0,1) != "/") path2="/" + path2;
 p.open("GET", "jar:" + url + "!" + path2, false);   
 p.send(null);   
 return p.responseText;
};

then call it by

Code: Select all

 alert(readfileinjar("http://mirror.meisterwerk.net/rmozdev/links/WebLinks.xpi", "/install.js") ) 
8) Biju
MacroEditor | http://QuickTools.MozDev.org | Edit files inside ZIP,JAR,XPI http://7-Zip.org
Cure Cancer http://www.grid.org/about | GNOME,*nix on MSWin32 http://CyGNOME.sf.net
User avatar
Thumper's Evil Twin
Posts: 6422
Joined: December 9th, 2003, 3:52 pm
Location: Glasgow, Scotland
Contact:

Post by Thumper's Evil Twin »

haha! awesome. I'd never thought of this. :)

- Chris
User avatar
c∂n
Posts: 700
Joined: June 28th, 2003, 8:31 am
Location: Longitude 0ish
Contact:

[ 480 ]

Post by c∂n »

what about view-source:chrome://browser/content/browser.xul ?
bijugc
Posts: 399
Joined: March 18th, 2003, 9:52 pm
Contact:

Post by bijugc »

So this also works

Code: Select all

view-source:jar:resource:///chrome/browser.jar!/content/browser/browser.xul

Now, how can we see the dir listing inside a zip?

.
Torisugari
Posts: 1634
Joined: November 4th, 2002, 8:34 pm
Location: Kyoto, Nippon (GMT +9)
Contact:

Post by Torisugari »

Hmm, interesting. In such a complicated scheme, what's their script security level?
Post Reply