Ask coding questions

← Back to all posts
How to access the virtual file system that Repl generates when someone opens a Repl
[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 (1443) [earned 5 cycles]
View Answer
Comments
hotnewtop
Highwayman (1443)

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.

[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.

Highwayman (1443)

@JadenGarcia
1) I don’t have a computer, this is an iPad :(
2) hmmm uh.
3) ok.

[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?.

Highwayman (1443)

@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.

[deleted]

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

Highwayman (1443)

@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.

[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)

Highwayman (1443)

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

[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.

Highwayman (1443)

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

[deleted]

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

Highwayman (1443)

@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?

Highwayman (1443)

@JadenGarcia who’s the right person anyways?

CSharpIsGud (925)

@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

Highwayman (1443)

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

[deleted]

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

CSharpIsGud (925)

@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

[deleted]

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

Highwayman (1443)

@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 :/

[deleted]

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

Highwayman (1443)

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

CSharpIsGud (925)

@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

[deleted]

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

[deleted]

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

[deleted]

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

Highwayman (1443)

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

[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.

CSharpIsGud (925)

@JadenGarcia Chromium is actually faster than chrome.

[deleted]

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

Highwayman (1443)

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

[deleted]

@Highwayman Nope.

echo 'text' | base64;
Highwayman (1443)

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

[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.

[deleted]

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

[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...

[deleted]

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

Highwayman (1443)

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

[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.

NoelB33 (344)

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

[deleted]

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

AmazingMech2418 (1044)

@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).

[deleted]

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

[deleted]

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

AmazingMech2418 (1044)

@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.

[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?

AmazingMech2418 (1044)

@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.

[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!

[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.

AmazingMech2418 (1044)

@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.

[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.

Highwayman (1443)

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

AmazingMech2418 (1044)

@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.

Highwayman (1443)

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

AmazingMech2418 (1044)

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

Highwayman (1443)

@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..

AmazingMech2418 (1044)

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

Highwayman (1443)

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

AmazingMech2418 (1044)

@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.

Highwayman (1443)

@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)

Highwayman (1443)

@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.

AmazingMech2418 (1044)

@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.

Highwayman (1443)

@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,

AmazingMech2418 (1044)

@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.

Highwayman (1443)

@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.

AmazingMech2418 (1044)

@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.

Highwayman (1443)

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

Highwayman (1443)

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

NoelB33 (344)

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

Highwayman (1443)

@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.

[deleted]

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

Highwayman (1443)

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

[deleted]

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

[deleted]

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

[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?

Highwayman (1443)

@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)

[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.

Highwayman (1443)

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

MatReiner (123)

data:text/html;utf-8,dataHere...

xxpertHacker (861)

@MatReiner You do realize that this was one of the original ideas he had, right? He used a data URL in the first code block.

Also, there are multiple things wrong with that data URL:

  • He specifically said "XML," and even gave the XML file used, your use of text/html is completely incorrect in this context
  • utf-8 is just plain incorrect. To set the charset, use charset=utf-8.
  • if dataHere... includes a hashtag, which the writer's XML did, then everything past it, including it, is totally ignored.