We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 6b05581 commit cab299fCopy full SHA for cab299f
src/playground.rs
@@ -257,17 +257,15 @@ pub fn eval(args: Args) -> Result<(), Error> {
257
.get("code")
258
.ok_or("Unable to retrieve param: query")?;
259
260
- let code = format!(
261
- "fn main(){{
262
- println!(\"{{:?}}\",{{
263
- {}
264
- }});
265
-}}",
266
- code
267
- );
+ if code.contains("fn main") {
+ api::send_reply(&args, "code passed to ?eval should not contain `fn main`")?;
+ } else {
+ let code = format!("fn main(){{ println!(\"{{:?}}\",{{ {} }}); }}", code);
+
+ let result = run_code(&args, &code)?;
+ api::send_reply(&args, &result)?;
+ }
268
269
- let result = run_code(&args, &code)?;
270
- api::send_reply(&args, &result)?;
271
Ok(())
272
}
273
0 commit comments