1 // Copyright 2013 the V8 project authors. All rights reserved. 2 // Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. 3 // 4 // Redistribution and use in source and binary forms, with or without 5 // modification, are permitted provided that the following conditions 6 // are met: 7 // 1. Redistributions of source code must retain the above copyright 8 // notice, this list of conditions and the following disclaimer. 9 // 2. Redistributions in binary form must reproduce the above copyright 10 // notice, this list of conditions and the following disclaimer in the 11 // documentation and/or other materials provided with the distribution. 12 // 13 // THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY 14 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 15 // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 16 // DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY 17 // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 18 // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 19 // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 20 // ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 21 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 22 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 24 description( 25 "Bug 7445, bug 7253: Handle Unicode escapes in regexps." 26 ); 27 28 var I3=/^\s*(fwd|re|aw|antw|antwort|wg|sv|ang|odp|betreff|betr|transf|reenv\.|reenv|in|res|resp|resp\.|enc|\u8f6c\u53d1|\u56DE\u590D|\u041F\u0435\u0440\u0435\u0441\u043B|\u041E\u0442\u0432\u0435\u0442):\s*(.*)$/i; 29 30 // Other RegExs from Gmail source 31 var Ci=/\s+/g; 32 var BC=/^ /; 33 var BG=/ $/; 34 35 // Strips leading Re or similar (from Gmail source) 36 function cy(a) { 37 //var b = I3.exec(a); 38 var b = I3.exec(a); 39 40 if (b) { 41 a = b[2]; 42 } 43 44 return Gn(a); 45 } 46 47 // This function replaces consecutive whitespace with a single space 48 // then removes a leading and trailing space if they exist. (From Gmail) 49 function Gn(a) { 50 return a.replace(Ci, " ").replace(BC, "").replace(BG, ""); 51 } 52 53 shouldBe('cy("Re: Hello")', '"Hello"'); 54 shouldBe('cy(": Hello")', '"Hello"'); 55 56 // --------------------------------------------------------------- 57 58 var regex = /^([^#<\u2264]+)([#<\u2264])(.*)$/; 59 shouldBe('regex.exec("24#Midnight").toString()', '"24#Midnight,24,#,Midnight"'); 60