Skip to content
← Back to Community
How to access the virtual file system that Repl generates when someone opens a Repl
Profile icon
[deleted]

Warning: Reading the following text requires basic-moderate understanding of the following

  • XML
  • HTML or XHTML
  • URLs:
    • Data URLs
    • File URLs
    • Absolute URLs
    • Relative URLs
  • Bash (the shell language)

The attached Repl contains:

chromium-browser --no-sandbox --start-maximized 'file:///home/runner/BrowserTest/test.xml' "data:text/xml;charset=utf-8,`cat ./test.xml`";

First it opens Chromium Browser which Repl already has, and Repl denies us from installing anything on a Repl, so I can't use Google Chrome, Firefox, TOR, etc.
It opens it with two flags --no-sandbox and --start-maximized, which are pretty self explanatory and aren't very cryptic.

It opens the following URLs: 'file:///home/runner/BrowserTest/test.xml', this is a browser URL, that directs to a file of my choice. This is my main problem, refer back to this URL later

"data:text/xml;charset=utf-8,cat ./test.xml", this is a dynamic string. It starts with data:text/xml;charset=utf-8, from that point, it reads my file at test.xml, which contains the following:

<?xml version="1.0" encoding="utf-8" standalone="yes"?> <root xml:lang="en"> <one>1</one> <two>2</two> <hash>#</hash> <three>3</three> <four>4</four> </root>

This would be fine... except that it is anything but fine. Nothing works as expected.

Run the Repl yourself, notice that it doesn't find the file.

Fork the Repl, notice that it's perfectly okay now.


This is because Repl automatically creates a fake Repl with everything that was in my Repl, but secretly uses a different file URL, so you can't damage my repl, but you can do whatever you want with the virtual copy.

This is partially because I'm using an absolute URL, so what about my other link? That's relative, so it should be fine, right? I wish...

URLs don't load anything past the # or, in English, a hashtag.

This occurs regardless of URL type, Firefox, Google Chrome. I don't know why

I tried encoding the hashtag using &#35;, but guess what? Lol, we have to encode it using itself... epic fail. It doesn't have a named HTML entity either, which doesn't matter since it's XML anyways.


So, all of that to get to my actual question.

The file URL only works if you own the Repl, when someone else uses it, it generates a new section in place of "file:///home/runner/BrowserTest/test.xml". The rest is unchanged. Is there a way to identify what the generated URL is?


Update

I realized I could've encoded the URL before using it. JavaScript has this functionality naively, and what does Repl.it have? That's right, NodeJS! So I can use node ./myFile.js, but I'm not sure how to feed this into the Bash file? Maybe using the back-tick quotes, but how do I make the JavaScript calculate and return a value?

Answered by Highwayman [earned 5 cycles]
View Answer
Voters
Profile icon
lemata846
Profile icon
Itsyourdriver
Profile icon
DynamicSquid
Profile icon
Highwayman
Comments
hotnewtop
Profile icon
Highwayman

Repl denies us from installing anything on a Repl

This is just straight up not true, I just installed Firefox last week! You have to use install-pkg.

Just use $PWD/test.xml, or maybe /home/runner/*/test.xml seeing as there aren’t any other xml files to look for.

Profile icon
[deleted]

@Highwayman This is a file URl. Can you try that on your computer?

Btw, I found a potential solution, but I don't know how to implement it, I'm updating the question right now.

Profile icon
Highwayman

@JadenGarcia

  1. I don’t have a computer, this is an iPad :(
  2. hmmm uh.
  3. ok.
Profile icon
[deleted]

@Highwayman install-pkg!? Really!? This is great news and will significantly improve what I'm capable of on Repl. Now I know it might be asking for a bit much, but can you make a simple Repl showing how to use it and invite me to it?.

Profile icon
Highwayman

@JadenGarcia it’s actually way easy, you just do
install-pkg PKGNAME, where PKGNAME is (of course) the name of the pkg you wish to install.

Profile icon
[deleted]

@Highwayman IPads are computers... Technically, humans are "computers" too, but I'm not using that definition of computer.

Profile icon
Highwayman

@JadenGarcia lol, eh. I have absolutely no idea how the file system works on my iPad, so... uh.. yeah... I woukdn’t even know where to begin.

Profile icon
[deleted]

@Highwayman I'm trying to install from files, like files I uploaded, like using wget to get a file from the internet. Like "ChromeSetup.dmg". (I don't think that's the filename, but whatever)

Profile icon
Highwayman

@JadenGarcia -_- you and I both know that there is no way my iPad has a terminal.

Profile icon
[deleted]

@Highwayman So, it's a computer. You probably just don't know how to access the developer terminal. Or in your case, you may be restricted from accessing it.

Profile icon
Highwayman

@JadenGarcia exxxxaaaactly. Also, there really isn’t a terminal on here (I’ve looked up how to get one before)

Profile icon
[deleted]

@Highwayman There's definitely a terminal... somewhere. Maybe if you access the factory reset boot terminal.

Profile icon
Highwayman

@JadenGarcia ? "Within the week"?

Profile icon
Highwayman

@JadenGarcia are you talking about when we were doing the variadic template stuff and you had a site you wanted me to look at about lambdas?

Profile icon
Highwayman

@JadenGarcia Spanish please XD

Profile icon
Highwayman

@JadenGarcia ohhh ok. 👍 lol.

Profile icon
Highwayman

@JadenGarcia who’s the right person anyways?

Profile icon
Highwayman

@JadenGarcia lol ok.

Profile icon
CSharpIsGud

@JadenGarcia you are really better off using install-pkg, if you can find what you want you want on apt, you can install it via install-pkg

Profile icon
Highwayman

@CSharpIsGud oh thank god someone who actually knows what’s going on anymore I’m dying XD

Profile icon
[deleted]

@CSharpIsGud Like Google Chrome, to replace the chromium browser?

Profile icon
CSharpIsGud

@JadenGarcia im sure chrome would be on apt its one of the most popular browsers, not sure why you want to run it on replit thought, its not worth it

Profile icon
[deleted]

@CSharpIsGud Why I'm running it through Repl.it is irrelevant. But Chrome is better than Chromium

Profile icon
Highwayman

@JadenGarcia I think if you do base64 encoding you can get the hashtag to work, but of course that requires you to base64 encode the file first :/

Profile icon
Highwayman
Profile icon
[deleted]

@Highwayman I updated the question already, read under the Update section at the bottom.

Profile icon
Highwayman

@JadenGarcia use process.argv to get command line args, then output the file encoded.

Profile icon
CSharpIsGud

@JadenGarcia Not really, chromium is basically open source chrome, to qoute the internet Chromium is an open-source browser project that forms the basis for the Chrome web browser. The biggest difference between the two browsers is that, while Chrome is based on Chromium, Google also adds a number of proprietary features to Chrome like automatic updates and support for additional video formats. I don't know of anything significant chrome can do that chromium can't

Profile icon
[deleted]

@Highwayman Actually, I remembered that there's a way to Base64 encode in Bash, now I find how to again.

Profile icon
Highwayman

@JadenGarcia ..ok lol

Profile icon
[deleted]

@Highwayman I'm not trying to output the file, but return it as a string.

Profile icon
[deleted]

@CSharpIsGud Oh, so it's be just as fast? I'll try to find if I can use TOR then.

Profile icon
Highwayman

@JadenGarcia $(CMD ARGS...) returns output I’m pretty sure, ya?

Profile icon
[deleted]

@Highwayman I have no clue. Since you brought it up, I think you'd know more about it than me, but I'ma try to find the Bash way of encoding.

Profile icon
Highwayman
Profile icon
CSharpIsGud

@JadenGarcia Chromium is actually faster than chrome.

Profile icon
[deleted]

@CSharpIsGud Well, that's incredibly helpful to note.

Profile icon
Highwayman

@JadenGarcia hm, you found the bash way to base64 encode?

Profile icon
[deleted]

@Highwayman Nope.

echo 'text' | base64;
Profile icon
Highwayman

@JadenGarcia lol. sick!

Profile icon
Highwayman

@JadenGarcia hm works, why are you sing nope again? Did I catch that sarcasm right?

Profile icon
[deleted]

@Highwayman Yeah it was. But turns out I need the Node way of doing it, because Bash encodes it. That's literally it, it's not in a format that can be read by a browser.

Profile icon
Highwayman

@JadenGarcia ? Really? How so?

Profile icon
[deleted]

@Highwayman Lol, nvm. I forgot to put base64 in the data URL.

Profile icon
Highwayman

@JadenGarcia XD there we go lol.

Profile icon
[deleted]

@Highwayman Finally, It's done! Perfect and so simple using native Bash methods. Didn't realize I had a bug in one of SF's main bash projects for a few months. Now to get back on SF...

Profile icon
Highwayman

@JadenGarcia yay!
.. yay?

Profile icon
[deleted]

@Highwayman I'm locked out of the account. :(

Profile icon
Highwayman

@JadenGarcia that’s why I’m confused, how are you gonna do it?

Profile icon
[deleted]

@Highwayman I'll wait a few months to update the code. No one's using the code anyways. The entire globe is currently preoccupied with a virus, so I've got time.

Profile icon
Highwayman

@JadenGarcia al...right... ok.

Profile icon
NoelB33

The only way to get a terminal is to jailbreak it and install NewTerm. @Highwayman

Profile icon
[deleted]

@NoelBryan Oh I forgot, you have to jailbreak to get root access on IOS devices. Android requires rooting too.

Profile icon
AmazingMech2418

@JadenGarcia To base64 encode a file, just do base64 <file name>. You could also always do cat <file name> | base64 as well, but that's more to type. You can also pipe it into another file (or the same file) to save it by doing something like base64 <file name> > <file name>, or just copy and paste from your terminal (would be best if repl.it terminal in this case, but if you are on Linux or have Bash installed on your computer separately, you could do it on your computer as well).

Profile icon
[deleted]

@AmazingMech2418 I already got it. Found how to nativly base64 encode in Bash, and posted the answer.

Profile icon
[deleted]

@AmazingMech2418 What does base64 "filename" do? will that override the file's data?

Profile icon
AmazingMech2418

@JadenGarcia Nope. To override the file's data, you need to pipe the result into the same file. base64 <filename> just encodes a file's contents in base64.

Profile icon
[deleted]

@AmazingMech2418 So it will read the file, encode the data, then use it however I defined the data to be used in my program, correct?

Profile icon
AmazingMech2418

@JadenGarcia Correct, given that your program is in Bash. If you want to use it in another language, you will either have to pipe the result or just base64 encode in the programming language. However, in Bash, you could set a variable and do whatever, pipe it into a file, etc.

Profile icon
[deleted]

@AmazingMech2418 I'm just using the file once, and don't want to keep another whole file in base64 since Repl storage is limited. But thanks anyways!

Profile icon
[deleted]

@AmazingMech2418 But since this is already answered, if you want you can help me with my other unanswered question at: How Higher Order Lambdas To Return a Variable Lambda.

Profile icon
AmazingMech2418

@JadenGarcia You could just pipe it into itself and override the data to just keep one file that is encoded in base64. However, base64 is longer than the original text.

Profile icon
[deleted]

@AmazingMech2418 That's why I mentioned Repl storage, the longer base64 (by about 1/3) will take more space, also I want to be able to edit the source file and just click "run" to see the program adapt to the updated file. I wouldn't want to destroy the file.

Profile icon
Highwayman

@NoelBryan that’s an ssh, not an actual terminal native, but ok.

Profile icon
AmazingMech2418
Profile icon
Highwayman

@AmazingMech2418 node_modules lul

Profile icon
AmazingMech2418

@Highwayman My other Node.JS repls are under 10KB, but the ones with servers are barely under 10MB. I don't think Node modules alone would multiply the storage usage by 1000.

Profile icon
Highwayman

@AmazingMech2418 ohhhh yes it would, express itself is massive check the package.json n stuff you’ll see XD

Profile icon
AmazingMech2418

@Highwayman 30 dependencies... Yeah, but I still don't think it would multiply by 1000.

Profile icon
Highwayman

@AmazingMech2418 eh, 🤷‍♂️. I guess it just is how it is. Besides, I’m pretty sure that the size measuring system on repl.it is kinda messed anyways so idk. But 1000 / 30 is around 3 or 4, yeah? So maybe it is..

Profile icon
AmazingMech2418

@Highwayman More like 30 or 40... (actually 33.333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333...)

Profile icon
Highwayman

@AmazingMech2418 oh oops I did 100/30 in my head instead of 1000/30 XD

Profile icon
AmazingMech2418

@Highwayman The issue is that I have 71MB already used, leaving room for only like 3 more Node.JS server repls and I am working on a project that is around the same size as recreating all of the G Suite apps (docs, slides, sheets, drive, etc.) and improving them, of course, called "iConn" which will need more than 3 more Node.JS servers and I don't have the money to get the hacker plan, so, now you probably see my problem.

Profile icon
Highwayman

@AmazingMech2418 don’t worry about space for now I’d say. I’ve gone well over that before and never lost a thing (I used to have around 168 MB)

Profile icon
AmazingMech2418

@Highwayman Why is there a limit then?

Profile icon
Highwayman

@AmazingMech2418 well because eventually they will actually enforce the limit. So basically it’s preferable that you stay under because we don’t want repl.it to die, but your pretty safe to just go over occasionally atm.

Profile icon
AmazingMech2418

@Highwayman But what if I need multiple Node.JS server repls up at the same time? For example, with iConn, I need the main iConn server, HoustonEverywhere, HoustonEverywhere Code (soon to be changed to CodeConn), iCom, ServerLink, IoTLink, and more once I get there.

Profile icon
Highwayman

@AmazingMech2418 hmmmm make 30 different alts to host them XD idk, 🤷‍♂️ Try putting it all in one repl, and have them listen on different ports. Since they probably overlap in terms of modules, it will reduce the amount of data you use. Also since server’s keep running on the latest release after they are deleted, you can just make the finished product, start the server, delete the repl, and then start the next server. Maybe that’d work,

Profile icon
AmazingMech2418

@Highwayman You can make it listen on multiple ports? I've tried that before and only port 3000 worked for some reason. However, all of them use the same modules, so any ideas there? The only thing I can think of is using separate html repls with one Node.JS repl, but then, Socket.io wouldn't work.

Profile icon
Highwayman

@AmazingMech2418 yes you can listen on 8080 or 7000 or 3000 or 6000... stuff like that, that’s 4 right there. You can put all of the servers in a single polygott repl and then have them run on the different ports. Maybe I’ll make a repl and test that, but it should be a thing I think.

Profile icon
AmazingMech2418

@Highwayman How would Repl.it manage the domains? Also, please make a test repl. I don't even really know what a polygott repl is.

Profile icon
Highwayman

@AmazingMech2418 idk... ok I’ll make a test repl hm.

Profile icon
Highwayman

@AmazingMech2418 ok, I made a test repl and it didn’t work DX

Profile icon
NoelB33

Wait there’s a difference? I don’t know my terminal stuff so I don’t know. Highwayman

Profile icon
Highwayman

@JadenGarcia done.
@NoelBryan
well, kinda... it might just be running all the commands on some VM in the cloud n’ stuff but I guess it doesn’t really make a difference necessarily... it depends basically.

Profile icon
[deleted]

@Highwayman Use Bash and chose what node js file to run. That should save lots of space.

Profile icon
Highwayman

@JadenGarcia I tried that, but it just didn’t work :(

Profile icon
[deleted]

@Highwayman And I did too, know the difference? It did work.

Profile icon
Highwayman

@JadenGarcia O.o HAXXXXX XD

Profile icon
[deleted]

@Highwayman So, you wanna see a Bash Repl example or no?

Profile icon
[deleted]

@Highwayman What are the odds that I've been trying to learn web development in C++ and was working on this CGI project, any you happen to have a web server in C++ as one of your most recent Repls? You don't care that I forked it and started updating/modifying it, right?

Profile icon
Highwayman

@JadenGarcia sorry I had something, that came up:

  1. yes I do I would definitely like to sorry that something came up.
  2. sure, but I actually suggest the one in share(the one I have is a fork of that that I’m messing around with)
Profile icon
Highwayman
Profile icon
[deleted]

@Highwayman Um, my keyboard's been broken for a few hours and I'm lazy, barely got it up again, I'll make the Bash repl and link you.

Profile icon
Highwayman

@JadenGarcia ok, cool! Hope your keyboard fixes up...well....?