Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(150)

Side by Side Diff: src/scanner-base.cc

Issue 6171001: Change interpretation of malformed \c? escapes in RegExp to match JSC. (Closed)
Patch Set: Addressed review comments. Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/parser.cc ('k') | test/cctest/test-parsing.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 713 matching lines...) Expand 10 before | Expand all | Expand 10 after
724 724
725 // Scan regular expression body: According to ECMA-262, 3rd, 7.8.5, 725 // Scan regular expression body: According to ECMA-262, 3rd, 7.8.5,
726 // the scanner should pass uninterpreted bodies to the RegExp 726 // the scanner should pass uninterpreted bodies to the RegExp
727 // constructor. 727 // constructor.
728 LiteralScope literal(this); 728 LiteralScope literal(this);
729 if (seen_equal) 729 if (seen_equal)
730 AddLiteralChar('='); 730 AddLiteralChar('=');
731 731
732 while (c0_ != '/' || in_character_class) { 732 while (c0_ != '/' || in_character_class) {
733 if (ScannerConstants::kIsLineTerminator.get(c0_) || c0_ < 0) return false; 733 if (ScannerConstants::kIsLineTerminator.get(c0_) || c0_ < 0) return false;
734 if (c0_ == '\\') { // escaped character 734 if (c0_ == '\\') { // Escape sequence.
735 AddLiteralCharAdvance(); 735 AddLiteralCharAdvance();
736 if (ScannerConstants::kIsLineTerminator.get(c0_) || c0_ < 0) return false; 736 if (ScannerConstants::kIsLineTerminator.get(c0_) || c0_ < 0) return false;
737 AddLiteralCharAdvance(); 737 AddLiteralCharAdvance();
738 } else { // unescaped character 738 // If the escape allows more characters, i.e., \x??, \u????, or \c?,
739 // only "safe" characters are allowed (letters, digits, underscore),
740 // otherwise the escape isn't valid and the invalid character has
741 // its normal meaning. I.e., we can just continue scanning without
742 // worrying whether the following characters are part of the escape
743 // or not, since any '/', '\\' or '[' is guaranteed to not be part
744 // of the escape sequence.
745 } else { // Unescaped character.
739 if (c0_ == '[') in_character_class = true; 746 if (c0_ == '[') in_character_class = true;
740 if (c0_ == ']') in_character_class = false; 747 if (c0_ == ']') in_character_class = false;
741 AddLiteralCharAdvance(); 748 AddLiteralCharAdvance();
742 } 749 }
743 } 750 }
744 Advance(); // consume '/' 751 Advance(); // consume '/'
745 752
746 literal.Complete(); 753 literal.Complete();
747 754
748 return true; 755 return true;
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
894 if (MatchKeywordStart(input, "with", 1, Token::WITH)) return; 901 if (MatchKeywordStart(input, "with", 1, Token::WITH)) return;
895 break; 902 break;
896 case UNMATCHABLE: 903 case UNMATCHABLE:
897 break; 904 break;
898 } 905 }
899 // On fallthrough, it's a failure. 906 // On fallthrough, it's a failure.
900 state_ = UNMATCHABLE; 907 state_ = UNMATCHABLE;
901 } 908 }
902 909
903 } } // namespace v8::internal 910 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/parser.cc ('k') | test/cctest/test-parsing.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698