Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Lexer support "@" character - used in email addresses and others - v 1.2.16 #7469

Closed
pdindak opened this issue May 15, 2014 · 11 comments
Closed

Comments

@pdindak
Copy link

pdindak commented May 15, 2014

Email address contains "@"

Uncaught Error: Lexer Error: Unexpected next character at columns 16-16 [@] in expression

This problem has been around for quite a while, really cannot get around this issue.

Thanks!

@Narretz
Copy link
Contributor

Narretz commented May 15, 2014

I'm confused. Isn't the lexer for parsing angular / Javascript expressions? Where would a @ come into play there?

@pdindak
Copy link
Author

pdindak commented May 15, 2014

A watch on an object with an email address used as user and name fields

Uncaught Error: Lexer Error: Unexpected next character at columns 16-16 [@] in expression [[email protected]]. angular.js:6489
throwError angular.js:6489
lex angular.js:6448
parser angular.js:6642
$get angular.js:7281
compileToFn angular.js:9214
$get.Scope.$watch angular.js:8546
obj.onUpdate widget?&user=[email protected]:989

function setUpSyncObject(scope, name, defaultValue, afterLoadCallback) {
// if (angular.isArray(defaultValue)) {
// scope[name] = [];
// }
// else {
// scope[name] = {};
// }
scope[name] = {};

var obj = {
name: name,
value: scope[name],
set: function(value) {
scope[name] = value;
},
get: function() {
return scope[name];
},
updated: function() {
scope.$apply();
},
onUpdate: function(callback) {
scope.$watch(name, callback, true);
},
defaultValue: defaultValue
};

syncObject[name] = new SyncObject(obj, widget, afterLoadCallback);
}

@caitp
Copy link
Contributor

caitp commented May 15, 2014

@pdinadk you can use object["[email protected]"] for example, $parse will be totally happy with that

@lgalfaso lgalfaso assigned lgalfaso and unassigned lgalfaso May 15, 2014
@pdindak
Copy link
Author

pdindak commented May 15, 2014

Thanks, caitp. Can you point me to where you think it would work with the parser? Not clear where you mean to use it as you described.

@caitp
Copy link
Contributor

caitp commented May 15, 2014

$scope.object = {
  '[email protected]': false,
  '[email protected]': false
};

$scope.$watch('object["[email protected]"]', listener);

function listener(newVal, oldVal) {
  // do something
}

@pdindak
Copy link
Author

pdindak commented May 15, 2014

Aha, ok Thanks! thought you meant the $watch, but was not sure.

@btford
Copy link
Contributor

btford commented May 21, 2014

I'm going to close this as "working as expected."

@jdenquin
Copy link

Same issue
Lexer Error: Unexpected next character at columns 4-4 [@] in expression [[email protected]].

when parsing a string using angular-ui tooltip-html, do I have to open an issue there? I think it comes from angular $parse

@caitp
Copy link
Contributor

caitp commented Jan 14, 2016

that's just not a valid expression syntax, @jdenquin. You probably want ['[email protected]'] or similar

@SylwesterKogowski
Copy link

SylwesterKogowski commented Oct 29, 2016

I have this: <div class="serviceNote" ng-click="showMainNoteDialog('Formularz Podatku 2014', 4008, 'e-mail do firmy o korekte swiadczeniz zlomowania auta Opel Astra &#39;info&#64;wilkohaag.nl&#39;;')">
And I get this: angular.min.js:114 Error: [$parse:lexerr] http://errors.angularjs.org/1.5.2/$parse/lexerr?p0=Unexpected%20nextharacter%20&p1=s%20122-122%20%5B%40%5D&p2=showMainNoteDialog('Formularz%20Podatku%202014'%2C%204008%2C%20'e-mail%do%firmy%o%20korekte%swiadczeniz%20zlomowania%20auta%Opel%20Astra%20'info%40wilkohaag.nl'%3B')

I even escaped the @ sign to &#64;, but that didn't help, of course I get the same error without escape.

At last I came to a conclusion, that using &#34; (escape of " sign) in this way:
<div class="serviceNote" ng-click="showMainNoteDialog('Formularz Podatku 2014', 4008, &#34;e-mail do firmy o korekte swiadczeniz zlomowania auta Opel Astra &#39;info&#64;wilkohaag.nl&#39;;&#34;)">

will work.

@gkalpak
Copy link
Member

gkalpak commented Oct 29, 2016

@SylwesterKogowski, this is because the browser will unescape &#39; to ' resulting in an invalid expression. You can simply escape ' with \'.

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

No branches or pull requests

8 participants