Changeset 18517 in webkit for trunk/JavaScriptCore/kjs/regexp.cpp


Ignore:
Timestamp:
Jan 1, 2007, 9:13:00 PM (18 years ago)
Author:
ddkilzer
Message:

JavaScriptCore:

Reviewed by Darin.

Modified pcre_compile() (and the functions that it calls) to work with patterns
containing null characters.

Covered by JavaScriptCore tests ecma_3/RegExp/octal-002.js and ecma_3/RegExp/regress-85721.js

  • kjs/regexp.cpp: (KJS::RegExp::RegExp): Changed to not null-terminate the pattern string and instead pass its length to pcre_compile.
  • pcre/pcre.h:
  • pcre/pcre_compile.c: (check_escape): (get_ucp): (is_counted_repeat): (check_posix_syntax): (compile_branch): (compile_regex): (pcre_compile): Added a parameter specifying the length of the pattern, which is no longer required to be null-terminated and may contain null characters. (pcre_compile2):
  • pcre/pcre_internal.h:
  • tests/mozilla/expected.html: Updated for the two tests that this patch fixes. Also updated failing results for ecma_3/RegExp/regress-100199.js which were not updated after bug 6257 was fixed.

WebCore:

Reviewed by Darin.

  • platform/RegularExpression.cpp: (WebCore::RegularExpression::Private::compile): Changed to not null-terminate the pattern string and instead pass its length to pcre_compile.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/kjs/regexp.cpp

    r18182 r18517  
    4848  int errorOffset;
    4949 
    50   UString pattern(p);
    51  
    52   pattern.append('\0');
    53   m_regex = pcre_compile(reinterpret_cast<const uint16_t*>(pattern.data()),
     50  m_regex = pcre_compile(reinterpret_cast<const uint16_t*>(p.data()), p.size(),
    5451                        options, &errorMessage, &errorOffset, NULL);
    5552  if (!m_regex) {
    5653    // Try again, this time handle any \u we might find.
    57     UString uPattern = sanitizePattern(pattern);
    58     m_regex = pcre_compile(reinterpret_cast<const uint16_t*>(uPattern.data()),
     54    UString uPattern = sanitizePattern(p);
     55    m_regex = pcre_compile(reinterpret_cast<const uint16_t*>(uPattern.data()), uPattern.size(),
    5956                          options, &errorMessage, &errorOffset, NULL);
    6057    if (!m_regex) {
Note: See TracChangeset for help on using the changeset viewer.