Skip to content

Commit b755c7a

Browse files
committed
FEAT/CHANGE: allowing @name to be a valid email! type
For a compatibility with Red language and also because it may be useful in dialects. Although `@name` is not a valid real email according RFC, one can construct invalid email values in many ways and so in real use for email apps, there should be a real additional email validation anyway. Related to: Oldes/Rebol-issues#1962
1 parent 8452d8c commit b755c7a

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

src/core/l-scan.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -782,12 +782,12 @@
782782
}
783783

784784
case LEX_CLASS_SPECIAL:
785-
if (HAS_LEX_FLAG(flags, LEX_SPECIAL_AT) && *cp != '<') return TOKEN_EMAIL;
785+
if (HAS_LEX_FLAG(flags, LEX_SPECIAL_AT) && *cp != '<') return TOKEN_EMAIL; // for case like: %61@b which is actually: a@b
786786
next_ls:
787787
switch (GET_LEX_VALUE(*cp)) {
788788

789-
case LEX_SPECIAL_AT:
790-
return -TOKEN_EMAIL;
789+
case LEX_SPECIAL_AT: /* @username */
790+
return TOKEN_EMAIL;
791791

792792
case LEX_SPECIAL_PERCENT: /* %filename */
793793
cp = scan_state->end;

src/tests/units/lexer-test.r3

+7
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@ Rebol [
2222

2323
===end-group===
2424

25+
===start-group=== "Email"
26+
--test-- "valid `emails`"
27+
--assert email? load {name@where}
28+
--assert email? load {@name} ;@@ https://github.com/Oldes/Rebol-issues/issues/1962
29+
30+
===end-group===
31+
2532
===start-group=== "SIGN before POUND char (issue #2319)"
2633
;@@ https://github.com/rebol/rebol-issues/issues/2319
2734
--test-- "sign-before-pound-1" --assert [- #"a"] = (load {-#"a"})

0 commit comments

Comments
 (0)