Changeset 28395 in webkit
- Timestamp:
- Dec 4, 2007, 11:08:28 AM (17 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/ChangeLog
r28370 r28395 1 2007-12-04 Darin Adler <darin@apple.com> 2 3 Reviewed by Geoff. 4 5 - fix first part of http://bugs.webkit.org/show_bug.cgi?id=16220 6 <rdar://problem/5625221> Crash opening www.news.com (CNet) 7 8 Test: fast/js/regexp-overflow.html 9 10 * pcre/pcre_compile.cpp: 11 (calculateCompiledPatternLengthAndFlags): Add room for the additional BRA/KET that 12 was generated in the compile code but not taken into account here. 13 1 14 2007-12-03 Darin Adler <darin@apple.com> 2 15 -
trunk/JavaScriptCore/pcre/pcre_compile.cpp
r28272 r28395 1510 1510 copy, which has to be moved up. The remainder can be handled by code 1511 1511 that is common with the non-zero minimum case below. We have to 1512 adjust the value or repeat_max, since one less copy is required. Once 1513 again, we may have to adjust any OP_RECURSE calls inside the group. */ 1512 adjust the value of repeat_max, since one less copy is required. */ 1514 1513 1515 1514 else { … … 2658 2657 length++; 2659 2658 if (maxRepeats > 0) length += (maxRepeats - 1) * (duplength + 3 + 2 * LINK_SIZE); 2659 if (maxRepeats > 1) length += 2 + 2 * LINK_SIZE; // BRA/KET created in else case 2660 2660 } 2661 2661 … … 2707 2707 return length; 2708 2708 } 2709 2710 #ifdef DEBUG2711 static void printCompiledRegExp(JSRegExp* re, int length)2712 {2713 printf("Length = %d top_bracket = %d top_backref = %d\n",2714 length, re->top_bracket, re->top_backref);2715 2716 if (re->options) {2717 printf("%s%s%s\n",2718 ((re->options & IsAnchoredOption) != 0)? "anchored " : "",2719 ((re->options & IgnoreCaseOption) != 0)? "ignores case " : "",2720 ((re->options & MatchAcrossMultipleLinesOption) != 0)? "multiline " : "");2721 }2722 2723 if (re->options & UseFirstByteOptimizationOption) {2724 char ch = re->first_byte & 255;2725 const char* caseless = (re->first_byte & REQ_IGNORE_CASE) ? " (ignores case)" : "";2726 if (isASCIIAlphanumeric(ch))2727 printf("First char = %c%s\n", ch, caseless);2728 else2729 printf("First char = \\x%02x%s\n", ch, caseless);2730 }2731 2732 if (re->options & UseRequiredByteOptimizationOption) {2733 char ch = re->req_byte & 255;2734 const char* caseless = (re->req_byte & REQ_IGNORE_CASE) ? " (ignores case)" : "";2735 if (isASCIIAlphanumeric(ch))2736 printf("Req char = %c%s\n", ch, caseless);2737 else2738 printf("Req char = \\x%02x%s\n", ch, caseless);2739 }2740 2741 // This debugging function has been removed from JavaScriptCore's PCRE2742 //pcre_printint(re, stdout);2743 }2744 #endif2745 2709 2746 2710 /************************************************* … … 2838 2802 2839 2803 *code++ = OP_END; 2840 2841 #ifndef DEBUG 2804 2805 ASSERT(code - codestart <= length); 2842 2806 if (code - codestart > length) 2843 2807 errorcode = ERR7; 2844 #endif2845 2808 2846 2809 /* Give an error if there's back reference to a non-existent capturing … … 2896 2859 } 2897 2860 2898 #ifdef DEBUG2899 printCompiledRegExp(re);2900 2901 /* This check is done here in the debugging case so that the code that2902 was compiled can be seen. */2903 if (code - codestart > length) {2904 (pcre_free)(re);2905 *errorptr = error_text(ERR7);2906 return NULL;2907 }2908 2909 #endif2910 2911 2861 if (numSubpatterns) 2912 2862 *numSubpatterns = re->top_bracket; -
trunk/LayoutTests/ChangeLog
r28372 r28395 1 2007-12-04 Darin Adler <darin@apple.com> 2 3 Reviewed by Geoff. 4 5 - test for first part of http://bugs.webkit.org/show_bug.cgi?id=16220 6 <rdar://problem/5625221> Crash opening www.news.com (CNet) 7 8 * fast/js/regexp-overflow-expected.txt: Updated. 9 * fast/js/resources/regexp-overflow.js: Added test cases. 10 1 11 2007-12-03 Dan Bernstein <mitz@apple.com> 2 12 -
trunk/LayoutTests/fast/js/regexp-overflow-expected.txt
r28058 r28395 1 Tests some regular expressions with braces in themthat used to overflow the regular expression compilation preflight computation.1 Tests some regular expressions that used to overflow the regular expression compilation preflight computation. 2 2 3 3 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". … … 7 7 PASS /^(\d{1,2})([ -:\/\.]{1})(\d{1,2})(\2{1})?(\d{2,4})?$/.exec("1:1").toString() is "1:1,1,:,1,," 8 8 PASS /^(\d{4})([ -:\/\.]{1})(\d{1,2})(\2{1})(\d{1,2})T(\d{1,2})([ -:\/\.]{1})(\d{1,2})(\7{1})(\d{1,2})Z$/.exec("1234:5:6T7/8/9Z").toString() is "1234:5:6T7/8/9Z,1234,:,5,:,6,7,/,8,/,9" 9 PASS /\[["'\s]{0,1}([\w-]*)["'\s]{0,1}([\W]{0,1}=){0,2}["'\s]{0,1}([\w-]*)["'\s]{0,1}\]$/.exec("[]").toString() is "[],,," 10 PASS /(x){0,2}/.exec("").toString() is "," 9 11 10 12 PASS successfullyParsed is true -
trunk/LayoutTests/fast/js/resources/regexp-overflow.js
r28058 r28395 1 1 description( 2 'Tests some regular expressions with braces in themthat used to overflow the regular expression compilation preflight computation.'2 'Tests some regular expressions that used to overflow the regular expression compilation preflight computation.' 3 3 ); 4 4 5 5 shouldBe('/(\\d)(\\1{1})/.exec("11").toString()', '"11,1,1"'); 6 6 7 shouldBe('/^(\\d{1,2})([ -:\\/\\.]{1})(\\d{1,2})(\\2{1})?(\\d{2,4})?$/.exec("1:1").toString()', '"1:1,1,:,1,,"'); 7 shouldBe('/^(\\d{4})([ -:\\/\\.]{1})(\\d{1,2})(\\2{1})(\\d{1,2})T(\\d{1,2})([ -:\\/\\.]{1})(\\d{1,2})(\\7{1})(\\d{1,2})Z$/.exec("1234:5:6T7/8/9Z").toString()', '"1234:5:6T7/8/9Z,1234,:,5,:,6,7,/,8,/,9"'); 8 9 shouldBe('/^(\\d{4})([ -:\\/\\.]{1})(\\d{1,2})(\\2{1})(\\d{1,2})T(\\d{1,2})([ -:\\/\\.]{1})(\\d{1,2})(\\7{1})(\\d{1,2})Z$/.exec("1234:5:6T7/8/9Z").toString()', 10 '"1234:5:6T7/8/9Z,1234,:,5,:,6,7,/,8,/,9"'); 11 12 shouldBe('/\\[["\'\\s]{0,1}([\\w-]*)["\'\\s]{0,1}([\\W]{0,1}=){0,2}["\'\\s]{0,1}([\\w-]*)["\'\\s]{0,1}\\]$/.exec("[]").toString()', 13 '"[],,,"'); 14 15 shouldBe('/(x){0,2}/.exec("").toString()', '","'); 8 16 9 17 debug('');
Note:
See TracChangeset
for help on using the changeset viewer.