News for hackers. Stuff that matters.
Re:A collaborative spreadsheet in less than 45 lines of JS, ... by mayop100 on Wednesday November 13, 2013 @10:17PM (#6730314)
It would be nice if people could lay off the script injections. It's clearly insecure, but that's not really the point. It makes the experience worse for everyone if you alert(), etc.
Re:A collaborative spreadsheet in less than 45 lines of JS, ... by jcampbell1 on Thursday November 14, 2013 @12:18AM (#6730696)
> It's clearly insecure, but that's not really the point.

No, that is the point. I even pointed it out hours ago: https://news.ycombinator.com/item?id=6727448

The failure is the lesson. The previous version was a clever hack written by a clever person. This is ignorance, and the lesson is that allowing users to run arbitrary code on other user's computers is bad idea.

Re:A collaborative spreadsheet in less than 45 lines of JS, ... by FiloSottile on Thursday November 14, 2013 @01:44AM (#6730982)
I'm pretty sure that OP knew the issue, not just you, so it's not ignorance. And it's not the moment to cite The Good Parts either.

There is no failure here to be seen. There is a clever hack to make a spreadsheet shared quick and dirty.

Just a reminder that all the JS code you run, in particular on jsFiddle, is untrusted and is part of the security model of the JS engine in your browser that evil JS code must not be able to do any harm. If it did, report it to the browser vendor and earn a bounty.

Re:A collaborative spreadsheet in less than 45 lines of JS, ... by X4 on Wednesday November 13, 2013 @10:26PM (#6730342)
Re:A collaborative spreadsheet in less than 45 lines of JS, ... by X4 on Wednesday November 13, 2013 @10:21PM (#6730326)
yup. I guess some couldn't resist the urge. I hope there aren't more malicious minds, trying to steal cookies or stuff.
Re:A collaborative spreadsheet in less than 45 lines of JS, ... by stuross on Wednesday November 13, 2013 @11:16PM (#6730474)
Almost certainly someone is stealing cookies and this should be taken down soon. However, I actually enjoyed this post and was really informative all around.
Re:A collaborative spreadsheet in less than 45 lines of JS, ... by FiloSottile on Wednesday November 13, 2013 @11:24PM (#6730490)
Fiddles run unsecure code by design, so they do in a separate domain.
Re:A collaborative spreadsheet in less than 45 lines of JS, ... by ehPReth on Wednesday November 13, 2013 @11:20PM (#6730480)
If the spreadsheet doesn't load you can watch the chaos unfold in real time by visiting the datastore's page directly: https://spreadsheet.firebaseio-demo.com/sy85U
Re:A collaborative spreadsheet in less than 45 lines of JS, ... by wikwocket on Thursday November 14, 2013 @12:44AM (#6730789)
Nice. I look forward to the full office suite in 60 lines of JS, the email client/server in 75 lines of JS, and of course the bitcoin exchange web app in 90 lines of JS.
Re:A collaborative spreadsheet in less than 45 lines of JS, ... by asiekierka on Thursday November 14, 2013 @02:14AM (#6731055)
Did you forget an operating system in 150 lines of JS? (Four libraries used)
Re:A collaborative spreadsheet in less than 45 lines of JS, ... by thatthatis on Friday November 15, 2013 @10:11AM (#6739826)
Not sure how many lines of js it uses, but here you go:

http://bellard.org/jslinux/

http://bellard.org/jslinux/tech.html

Re:A collaborative spreadsheet in less than 45 lines of JS, ... by epsylon on Thursday November 14, 2013 @01:41PM (#6734425)
I can build a JS interpreter in 1 line of JS.
Re:A collaborative spreadsheet in less than 45 lines of JS, ... by yurikoval on Thursday November 14, 2013 @03:13AM (#6731236)
I think you can pull off Bitcoin in 89 lines.
Re:A collaborative spreadsheet in less than 45 lines of JS, ... by gummydude on Thursday November 14, 2013 @01:00AM (#6730844)
that would be a very2 long lines
Re:A collaborative spreadsheet in less than 45 lines of JS, ... by projectramo on Wednesday November 13, 2013 @10:28PM (#6730351)
I am waiting for someone to reproduce healthcare.gov with 100 lines of code...
Re:A collaborative spreadsheet in less than 45 lines of JS, ... by ics on Thursday November 14, 2013 @12:13AM (#6730680)

    <h1>Alabama</h1>
    <p>Please call 205-XXX-XXXX for more information.</p>
    <h1>Alaska</h1>
    <p>Please call 907-XXX-XXXX for more information.</p>
    <h1>Arizona</h1>
    <p>Please call 480-XXX-XXXX for more information.</p>
    <h1>Arkansas</h1>
    <p>Please call 479-XXX-XXXX for more information.</p>
    ...
Who needs doctypes, titles, or bodies...
Re:A collaborative spreadsheet in less than 45 lines of JS, ... by camus2 on Wednesday November 13, 2013 @10:34PM (#6730363)
that's the spirit ! seriously it would be an awesome idea to create a website with challenges like that. create a substractive synthesizer in js in less than 1k, like old demos
Re:A collaborative spreadsheet in less than 45 lines of JS, ... by sbirch on Wednesday November 13, 2013 @11:26PM (#6730511)
Re:A collaborative spreadsheet in less than 45 lines of JS, ... by fareesh on Thursday November 14, 2013 @12:45AM (#6730793)
I think the title should warn users of the various remote injection vulnerabilities present in the script. It took about 5 seconds for the page to change to xhamster
Re:A collaborative spreadsheet in less than 45 lines of JS, ... by imdsm on Thursday November 14, 2013 @07:25AM (#6731888)
Which would have been extremely embarrassing for someone at work. Luckily, that didn't happen to me.
Re:A collaborative spreadsheet in less than 45 lines of JS, ... by Goddel2 on Wednesday November 13, 2013 @10:25PM (#6730340)
Wow this link took about 30 seconds to turn into porn. Be warned.
Re:A collaborative spreadsheet in less than 45 lines of JS, ... by mothertrouble on Wednesday November 13, 2013 @11:27PM (#6730513)
WARNING: Could there be some kind of script attack ? My Safari browser freezes with 'foo' alert message from this site and it has placed itself as default website so whenever I reopen safari it freezes again.

Let me know if you know how to fix this.

Re:A collaborative spreadsheet in less than 45 lines of JS, ... by elisee on Thursday November 14, 2013 @12:03AM (#6730641)
I guess you could start Safari while offline to prevent the page from loading and change back your default page to something sane?
Re:A collaborative spreadsheet in less than 45 lines of JS, ... by phaemon on Thursday November 14, 2013 @08:53AM (#6732222)
It's probably just restoring your previous session. Hold down Shift when starting Safari to avoid loading the old session data.
Re:A collaborative spreadsheet in less than 45 lines of JS, ... by EGreg on Thursday November 14, 2013 @05:56AM (#6731667)
How can JS make some page your default? Strange
Re:A collaborative spreadsheet in less than 45 lines of JS, ... by leokun on Wednesday November 13, 2013 @10:53PM (#6730416)
Collaborative eval with the world, I'm glad I wasn't logged into jsfiddle when I opened that.
Re:A collaborative spreadsheet in less than 45 lines of JS, ... by FiloSottile on Wednesday November 13, 2013 @10:58PM (#6730426)
Since jsFiddles run user-generated code by design, I hope that they correctly sandbox and use HTTP-only cookies anyway.
Re:A collaborative spreadsheet in less than 45 lines of JS, ... by leokun on Wednesday November 13, 2013 @11:06PM (#6730448)
That's a great point. A restricted iframe on a separate domain + httpOnly session cookies just to be safe would do it.
Re:A collaborative spreadsheet in less than 45 lines of JS, ... by mintplant on Wednesday November 13, 2013 @11:32PM (#6730528)
That's what they do already.
Re:A collaborative spreadsheet in less than 45 lines of JS, ... by rjuyal on Thursday November 14, 2013 @02:10AM (#6731045)
Now I really love the feature of Chrome, "Prevent this window from creating new dialog box" ( or something like that ). Some *$%#@ put alert in the cell.
Re:A collaborative spreadsheet in less than 45 lines of JS, ... by Breefield on Wednesday November 13, 2013 @10:02PM (#6730255)
Careful, this code runs eval() on all spreadsheet fields. Someone can "collaboratively" steal your jsfiddle.net cookies.
Re:A collaborative spreadsheet in less than 45 lines of JS, ... by mintplant on Wednesday November 13, 2013 @11:13PM (#6730467)
The code runs on the fiddle.jshell.net domain.
Re:A collaborative spreadsheet in less than 45 lines of JS, ... by Breefield on Wednesday November 13, 2013 @11:26PM (#6730504)
that's good :) did not realize
Re:A collaborative spreadsheet in less than 45 lines of JS, ... by camus2 on Wednesday November 13, 2013 @10:44PM (#6730394)
one could use a function constructor instead of eval to try to mitigate XSS.
Re:A collaborative spreadsheet in less than 45 lines of JS, ... by fekberg on Thursday November 14, 2013 @12:22AM (#6730713)
Yeah that was fun until I got an alert box in my face.
Re:A collaborative spreadsheet in less than 45 lines of JS, ... by RokStdy on Wednesday November 13, 2013 @10:18PM (#6730318)
I like the craziness that this devolved into. It's funny when a bunch of people are all editing like mad.

I had the thought that it'd be fun to have a contest using jsfiddle to start from some point, like the excel (lite) clone in 30 lines, and add the best/coolest feature in some limit of lines.

It's really wonderful how ingenuity stacks.

Re:A collaborative spreadsheet in less than 45 lines of JS, ... by krapp on Wednesday November 13, 2013 @10:55PM (#6730417)
Such hax.

I wonder if a collaborative drawing app could be made with this, using canvas.. I keep trying to figure out exactly how it works but then sparkleponies and alerts everywhere...

Re:A collaborative spreadsheet in less than 45 lines of JS, ... by ianbicking on Wednesday November 13, 2013 @11:57PM (#6730612)
Re:A collaborative spreadsheet in less than 45 lines of JS, ... by jmacd on Thursday November 14, 2013 @07:11AM (#6731848)
Re:A collaborative spreadsheet in less than 45 lines of JS, ... by mmastrac on Wednesday November 13, 2013 @11:31PM (#6730527)
I think I crashed it (ie: Chrome hard lockup on the tab) with this:

=location.href='google.com'

Re:A collaborative spreadsheet in less than 45 lines of JS, ... by jcampbell1 on Thursday November 14, 2013 @12:13AM (#6730684)
That will just throw a frame error because of the X-Frame-Options header, which is caught quickly.

Browsers tend to have more problem with =while(1){}

Re:A collaborative spreadsheet in less than 45 lines of JS, ... by iancarroll on Thursday November 14, 2013 @09:27AM (#6732432)
Somebody has created a bot to put script lyrics in the spreadsheet ._.
Re:A collaborative spreadsheet in less than 45 lines of JS, ... by golergka on Thursday November 14, 2013 @10:31AM (#6732826)
Is it a bot or injection that maintains itself?
Re:A collaborative spreadsheet in less than 45 lines of JS, ... by justinwi on Wednesday November 13, 2013 @09:20PM (#6730120)
Sweet. How do you do I make it so not every Joe can hack the sheet?
Re:A collaborative spreadsheet in less than 45 lines of JS, ... by joshribakoff on Wednesday November 13, 2013 @10:06PM (#6730271)
You'd have to parse the cells as some sort of DSL that only allows mathematical tokens, as opposed to eval which allows access to the full arsenal of the JS language. But I think excel is Turing complete
Re:A collaborative spreadsheet in less than 45 lines of JS, ... by wwweston on Wednesday November 13, 2013 @10:58PM (#6730424)
Brings up the interesting question -- I wonder what turing-complete DSLs have drop-in JS libraries you could use to replace the call to "eval" here.
Re:A collaborative spreadsheet in less than 45 lines of JS, ... by icebraining on Thursday November 14, 2013 @07:29AM (#6731900)
Re:A collaborative spreadsheet in less than 45 lines of JS, ... by gmjoe on Wednesday November 13, 2013 @09:51PM (#6730220)
Oh boy. I can't wait to see what someone else can do with 60 lines of JS, and two libraries used!!

[Note: not being sarcastic. Think this is a genuinely awesome way to respond to first post!]

Re:A collaborative spreadsheet in less than 45 lines of JS, ... by FiloSottile on Wednesday November 13, 2013 @11:34PM (#6730538)
I would love to read about who/how is blocking XSS and censoring!
Re:A collaborative spreadsheet in less than 45 lines of JS, ... by mintplant on Wednesday November 13, 2013 @11:39PM (#6730554)
Oh, that's me: http://jsfiddle.net/sy85U/31/

Just a very quick, crude little hack.

Re:A collaborative spreadsheet in less than 45 lines of JS, ... by FiloSottile on Wednesday November 13, 2013 @11:42PM (#6730569)
You know what would be cool? Injecting this modified version to all clients, so that everybody act as a censor.
Re:A collaborative spreadsheet in less than 45 lines of JS, ... by granjef3 on Thursday November 14, 2013 @12:27AM (#6730733)
added an array for blocked words; http://jsfiddle.net/sy85U/47/
Re:A collaborative spreadsheet in less than 45 lines of JS, ... by yread on Thursday November 14, 2013 @04:22AM (#6731438)
yeah blocking . (a dot, decimal numbers should be allowed) is a bit too restrictive although it works really well.
Re:A collaborative spreadsheet in less than 45 lines of JS, ... by rnl on Thursday November 14, 2013 @04:28AM (#6731453)
Re:A collaborative spreadsheet in less than 45 lines of JS, ... by 10098 on Wednesday November 13, 2013 @10:41PM (#6730386)
I think we broke it, the fiddle no longer works for me
Re:A collaborative spreadsheet in less than 45 lines of JS, ... by kav-ya on Wednesday November 13, 2013 @10:58PM (#6730425)
Re:A collaborative spreadsheet in less than 45 lines of JS, ... by mariocesar on Wednesday November 13, 2013 @10:32PM (#6730361)
I like that everyone is collaborating to keep N S A in the last columns, that is team work !
Re:A collaborative spreadsheet in less than 45 lines of JS, ... by srobertson on Wednesday November 13, 2013 @10:12PM (#6730296)
very cool, probably need a few 100 more lines of code to stop XSS but awesome none the less.
Re:A collaborative spreadsheet in less than 45 lines of JS, ... by njsubedi on Wednesday November 13, 2013 @11:41PM (#6730564)
I'm trying to remove the location.href thing outta there! Annoying!
Re:A collaborative spreadsheet in less than 45 lines of JS, ... by cm-t on Thursday November 14, 2013 @04:20AM (#6731430)
Ooups, someone has having success with XSS :/
Re:A collaborative spreadsheet in less than 45 lines of JS, ... by Demiurge on Wednesday November 13, 2013 @11:19PM (#6730478)
lol, I think I just got hacked from that
Re:A collaborative spreadsheet in less than 45 lines of JS, ... by EGreg on Thursday November 14, 2013 @05:53AM (#6731659)
Why not just use TogetherJS securely?
Re:A collaborative spreadsheet in less than 45 lines of JS, ... by Eduard on Wednesday November 13, 2013 @11:24PM (#6730494)
did someone just execute remote javascript`?
Re:A collaborative spreadsheet in less than 45 lines of JS, ... by newbrict on Wednesday November 13, 2013 @11:53PM (#6730602)
someone just broke everything hahaha
Re:A collaborative spreadsheet in less than 45 lines of JS, ... by maemilius on Wednesday November 13, 2013 @10:21PM (#6730331)
And someone killed it...

EDIT: Nevermind, it's back.

Re:A collaborative spreadsheet in less than 45 lines of JS, ... by vj44 on Wednesday November 13, 2013 @09:45PM (#6730208)
Dope.
Re:A collaborative spreadsheet in less than 45 lines of JS, ... by hkon on Thursday November 14, 2013 @04:49AM (#6731506)
wow it's alive