Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Illegal token syntax error in windows-edited JavaScript from carriage return character #365

Closed
paulb777 opened this issue Aug 2, 2011 · 5 comments

Comments

@paulb777
Copy link
Contributor

paulb777 commented Aug 2, 2011

JavaScript parsing completely fails with one single "Ilegal token" error message if the file contains any carriage return characters - hex 0xd or string - '\r'

Proposed fix:

--- a/lib/ace/narcissus/jslex.js
+++ b/lib/ace/narcissus/jslex.js
@@ -166,7 +166,7 @@ Tokenizer.prototype = {
break;
}
}

  •        } else if (ch !== ' ' && ch !== '\t') {
    
  •        } else if (ch !== ' ' && ch !== '\t' && ch !== '\r') {
             this.cursor--;
             return;
         }
    

On my branch at paulb777@6d350c8

@fjakobs
Copy link
Contributor

fjakobs commented Aug 2, 2011

I can't reproduce it. Which version of Ace are you using? Does it happen in http://ajaxorg.github.com/ace/build/editor.html?

@paulb777
Copy link
Contributor Author

paulb777 commented Aug 2, 2011

I can reproduce in http://ajaxorg.github.com/ace/ if I drag and drop a file to it from the Mac Finder. Note that drag and drop does not work in http://ajaxorg.github.com/ace/build/editor.html.

Did the file you tried really has a hex 0d in it. I've used emacs -> Meta-x hexl-mode to verify. Is there a way to do attachments in github issues? If so, I could attach a zip with an example file.

My Ace version is about a week old, but it doesn't look like the recent sources have changed anything in jslex.

@paulb777 paulb777 closed this as completed Aug 2, 2011
@paulb777 paulb777 reopened this Aug 2, 2011
@fjakobs
Copy link
Contributor

fjakobs commented Aug 3, 2011

Could you send my the zip via mail to [email protected]?

@paulb777
Copy link
Contributor Author

paulb777 commented Aug 3, 2011

I found a way to create a problematic file on the Mac:

  1. Create any javascript file with an extra character
  2. Use tr to translate the extra character to a carriage return
  3. Drag and drop the resulting file from the finder to http://ajaxorg.github.com/ace/

Illegal token will show up in the margin
I'll also email you the y.js in a zipfile

$ cat x.js
var x;e

$ tr "e" "\r" < x.js > y.js
paulb$ od x.js
0000000 060566 020162 035570 005145 000012
0000011
$ od y.js
0000000 060566 020162 035570 005015 000012
0000011
$ cat y.js
var x;

$

@fjakobs
Copy link
Contributor

fjakobs commented Aug 4, 2011

Thanks Paul!. I was finally able to reproduce it. Updating narcissus fixed the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants