Comments (15)
It may be obvious but in addition to jailed.js all other files from lib folder must be also available. If these files are around the basic example works.
from jailed.
And what happens then? Is there some error message on the console?
from jailed.
Sorry. I should have specified. I get this Error message: Uncaught TypeError: Cannot read property 'foo' of null
And when I dump plugin into the console, remote's value is null.
from jailed.
I see, the plugin takes some time to initialize and it happens asynchronously. When you just created the Plugin instance with new jailed.Plugin(pluginCode, api);
, the connection to the plugin is not yet ready at the same moment, so you cannot simply invoke plugin.remote.foo()
right after creation.
Instead, use the whenConnected()
one-off event to postpone the usage upon the plugin initialization. This can be achieved by replacing your last line of code with something like:
var start = function() {
plugin.remote.foo();
}
plugin.whenConnected(start);
from jailed.
That make sense, but this still doesn't work. The error is gone, but I neither get an alert nor the "started" message in the console.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="jailed.js"></script>
</head>
<body>
<div id="content"></div>
<script>
var api = {
alert: alert
};
var pluginCode = "application.setInterface({\n";
pluginCode += "foo: function() {\n";
pluginCode += " application.remote.alert('hi');\n";
pluginCode += "}});"
console.log(pluginCode);
var plugin = new jailed.Plugin(pluginCode, api);
plugin.whenConnected(function() {
console.log('started');
plugin.remote.foo();
});
</script>
<body>
</html>
from jailed.
- which version of jailed do you use? (from the release, or from the repo?)
- Does it work if launched from a web-server, and not locally? (I am not sure if it should work locally at all...)
from jailed.
I used 0.2.0.
I haven't tried it from a server. The documentation made it seem as if it could work as a client-only app, but maybe I misunderstood it.
from jailed.
It is indeed a client-only app, but there are some security restricitons of the browser arising when you launch it from a local filesystem. It should (in theory) work locally as well, otherwise there is a bug. Can you please try to use the recent sources from the repository, in order to see if the problem is not yet fixed?
from jailed.
The latest version still says it's 0.2.0. Did you make changes without bumping the number?
from jailed.
I just downloaded the distribution again and tried it on a different Mac. It doesn't work in Chrome, and no errors appear in the console.
It also doesn't work in Safari, but I see this: [Error] SyntaxError: DOM Exception 12: An invalid or illegal string was specified. (_pluginWeb.js, line 50)
from jailed.
Firefox: An iframe which has both allow-scripts and allow-same-origin for its sandbox attribute can remove its sandboxing. index.html
The character encoding of a framed document was not declared. The document may appear different if viewed without the document framing it.
from jailed.
The latest version still says it's 0.2.0. Did you make changes without bumping the number?
Yep, this is what I ment. There are a lot of changes committed to the repo but not yet released. Please go here: https://github.com/asvd/jailed and click "Download zip" button, you will get the fresh sources.
from jailed.
I did that and got the above errors.
from jailed.
Another issue in your code: if you initialize a plugin out of a string, it should be DynamicPlugin, not a Plugin (which is used when code is stored in a file). Your example works for me locally with such a fix.
from jailed.
@asvd Even with DynamicPlugin i get Cannot read property 'foo' of null
.
from jailed.
Related Issues (20)
- unable to find application object
- Dom manipulation in jailed HOT 1
- Write code without application.remote HOT 2
- Just tried the base example - Getting permission issue HOT 5
- Why is the Web Worker inside an iframe? HOT 4
- Exposing values from the app to the jailed worker. HOT 1
- Best way to pass large data set into jailed script (browser)?
- Cannot read property 'whenEmitted' of undefined
- Add setting for "fallback to iframe jailing only" functionality, and timeout value
- Improve Jail Isolation via Content-Security-Policy HOT 1
- CVE-2022-23923 HOT 2
- Pass values to jailed code HOT 2
- Passing interface with sub functions not working
- Sandbox Escape Bug in jailed with Node.js
- Sandbox Escape Bug in jailed with Node.js
- Sandbox Escape in jailed with Node.js
- Sandbox Escape Bug in jailed with Node.js
- Sandbox Escape Bug in jailed with Node.js
- Sandbox Escape Bug in jailed with Node.js
- Sandbox Escape Bug in jailed with Node.js
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jailed.