Skip to content
This repository has been archived by the owner on Feb 12, 2022. It is now read-only.

Optimization for RegExp #579

Closed
garycourt opened this issue May 5, 2017 · 3 comments
Closed

Optimization for RegExp #579

garycourt opened this issue May 5, 2017 · 3 comments

Comments

@garycourt
Copy link

garycourt commented May 5, 2017

At the time of this issue, Prepack is compiling new RegExps from this:

global.a = /abc/;

to this:

(function () {
  var _$0 = RegExp;
  var _$1 = Object.defineProperty;

  var _0 = _$0("abc", "");

  var $$0 = {
    enumerable: false,
    configurable: false,
    writable: true
  };
  $$0.value = 0;

  _$1(_0, "lastIndex", $$0);

  a = _0;
})();

I am highly skeptical that this is faster at runtime then the original code. Please correct me if I'm wrong.

@NTillmann
Copy link
Contributor

I have noticed that as well. It can certainly better. When I looked at it myself, I got a bit confused as to whether all browsers define the same special properties on RegEx, that's something else to look into. In any case, a freshly defined RegExp shouldn't need any such property definitions.

@jacktuck
Copy link

jacktuck commented Aug 8, 2017

What about ReDOS? Could that path be optimized?

https://www.owasp.org/index.php/Regular_expression_Denial_of_Service_-_ReDoS

@hermanventer
Copy link
Contributor

I'm not sure what you are asking. Are you concerned about evil regexp strings breaking Prepack, or are you asking if Prepack could find vulnerable uses of regexp in the code it is prepacking?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants