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

Side by Side Diff: src/regexp/regexp-parser.cc

Issue 1824613002: [regexp] require exact match for unicode property names. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 9 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 | « no previous file | test/mjsunit/harmony/regexp-property-blocks.js » ('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 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/regexp/regexp-parser.h" 5 #include "src/regexp/regexp-parser.h"
6 6
7 #include "src/char-predicates-inl.h" 7 #include "src/char-predicates-inl.h"
8 #include "src/factory.h" 8 #include "src/factory.h"
9 #include "src/isolate.h" 9 #include "src/isolate.h"
10 #include "src/objects-inl.h" 10 #include "src/objects-inl.h"
(...skipping 827 matching lines...) Expand 10 before | Expand all | Expand 10 after
838 static_cast<uc16>(trail)); 838 static_cast<uc16>(trail));
839 return true; 839 return true;
840 } 840 }
841 } 841 }
842 Reset(start); 842 Reset(start);
843 } 843 }
844 return result; 844 return result;
845 } 845 }
846 846
847 #ifdef V8_I18N_SUPPORT 847 #ifdef V8_I18N_SUPPORT
848 bool IsExactPropertyValueAlias(const char* property_name, UProperty property,
849 int32_t property_value) {
850 const char* short_name =
851 u_getPropertyValueName(property, property_value, U_SHORT_PROPERTY_NAME);
852 if (short_name != NULL && strcmp(property_name, short_name) == 0) return true;
853 for (int i = 0;; i++) {
854 const char* long_name = u_getPropertyValueName(
855 property, property_value,
856 static_cast<UPropertyNameChoice>(U_LONG_PROPERTY_NAME + i));
857 if (long_name == NULL) break;
858 if (strcmp(property_name, long_name) == 0) return true;
859 }
860 return false;
861 }
862
848 bool LookupPropertyClass(UProperty property, const char* property_name, 863 bool LookupPropertyClass(UProperty property, const char* property_name,
849 ZoneList<CharacterRange>* result, Zone* zone) { 864 ZoneList<CharacterRange>* result, Zone* zone) {
850 int32_t property_value = u_getPropertyValueEnum(property, property_name); 865 int32_t property_value = u_getPropertyValueEnum(property, property_name);
851 if (property_value == UCHAR_INVALID_CODE) return false; 866 if (property_value == UCHAR_INVALID_CODE) return false;
852 867
868 // We require the property name to match exactly to one of the property value
869 // aliases. However, u_getPropertyValueEnum uses loose matching.
870 if (!IsExactPropertyValueAlias(property_name, property, property_value)) {
871 return false;
872 }
873
853 USet* set = uset_openEmpty(); 874 USet* set = uset_openEmpty();
854 UErrorCode ec = U_ZERO_ERROR; 875 UErrorCode ec = U_ZERO_ERROR;
855 uset_applyIntPropertyValue(set, property, property_value, &ec); 876 uset_applyIntPropertyValue(set, property, property_value, &ec);
856 bool success = ec == U_ZERO_ERROR && !uset_isEmpty(set); 877 bool success = ec == U_ZERO_ERROR && !uset_isEmpty(set);
857 878
858 if (success) { 879 if (success) {
859 uset_removeAllStrings(set); 880 uset_removeAllStrings(set);
860 int item_count = uset_getItemCount(set); 881 int item_count = uset_getItemCount(set);
861 int item_result = 0; 882 int item_result = 0;
862 for (int i = 0; i < item_count; i++) { 883 for (int i = 0; i < item_count; i++) {
(...skipping 638 matching lines...) Expand 10 before | Expand all | Expand 10 after
1501 return false; 1522 return false;
1502 } 1523 }
1503 terms_.Add(new (zone()) RegExpQuantifier(min, max, quantifier_type, atom), 1524 terms_.Add(new (zone()) RegExpQuantifier(min, max, quantifier_type, atom),
1504 zone()); 1525 zone());
1505 LAST(ADD_TERM); 1526 LAST(ADD_TERM);
1506 return true; 1527 return true;
1507 } 1528 }
1508 1529
1509 } // namespace internal 1530 } // namespace internal
1510 } // namespace v8 1531 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | test/mjsunit/harmony/regexp-property-blocks.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698