microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
164.5k stars 29.39k forks source link

"Invalid regular expression" using `PHOTO(?s)(.*)REV` despite `regex101.com` validating it. #216105

Open RokeJulianLockhart opened 5 months ago

RokeJulianLockhart commented 5 months ago
Does this issue occur when all extensions are disabled? Yes
VS Code Version code-insiders-1.91.0-1718259485.el8.rpm
OS Version cpe:/o:fedoraproject:fedora:40

Steps to Reproduce

  1. Enter .VCF data containing a PHOTO element, with a REV element beneath it:

    BEGIN:VCARD
    VERSION:3.0
    PRODID;VALUE=TEXT:ez-vcard 0.11.3
    FN:Placeholder
    UID:47759cae-7de1-4ae5-82c1-b3bc560e90da
    PHOTO;ENCODING=BASE64;TYPE=GIF:R0lGODdhYABgAPAAALccHMlFJiH5BAEAAAEALAAAAABgAGAAAAJuhI+py+0Po5y02ouz3rz7D4biSJbmiabqyrbuC8fyTNf2jef6zvf+DwwKh8Si8YhMKpfMpvMJjUqn1Kr1is1qt9yu9wsOi8fksvmMTqvX7Lb7DY/L5/S6/Y7P6/f8vv8PGCg4SFhoeIiYqLiIUgAAOw==
    REV;VALUE=DATE-AND-OR-TIME:20240224T161008Z
    END:VCARD
  2. Try to select those using PHOTO(?s)(.*)REV at https://regex101.com./#.

    This shall work.

  3. Test it in VS Code:

    1. Invalid regular expression: /PHOTO(?s)(.*)REV/gu: Invalid group

    2. image

IllusionMH commented 5 months ago

Editor find widget uses JS regexp engine. If you switch to ECMAScript(JavaScript) in regex101 you'll see error as well.

On another note: VS Code doesn't match new line with .* for perf reasons. [\s\S\n]* should match everything across multiple lines.

RokeJulianLockhart commented 5 months ago

https://github.com/microsoft/vscode/issues/216105

@IllusionMH, is there no way to force VS Code to match /n with .*?

IllusionMH commented 5 months ago

[\s\S\n]* should match everything across multiple lines.

\n should be mentioned in regexp explicitly to force multiline matches

mjbvz commented 5 months ago

Seems by design but moving upstream to confirm

IllusionMH commented 5 months ago

@mjbvz this issue is about VS Code search widget, not related to TS at all.

RyanCavanaugh commented 5 months ago

This relates to VS Code, not TS:

image

mjbvz commented 5 months ago

@IllusionMH That's what I thought too but the issue is very unclear:

Image

@RokeJulianLockhart Please provide full repo steps

RokeJulianLockhart commented 5 months ago

https://github.com/microsoft/vscode/issues/216105#issuecomment-2174362276

@mjbvz, what reproduction steps are absent? I've provided sample code and the expression itself, and the version of VSC I'm using.

mjbvz commented 5 months ago

Share what are you doing. Provide exact steps (with screenshots if useful)

RedCMD commented 5 months ago

@RokeJulianLockhart you hadn't stated that the bug was about the ctrl+F Find regex

RokeJulianLockhart commented 5 months ago

https://github.com/microsoft/vscode/issues/216105#issuecomment-2174555495

@mjbvz, per the undermentioned, I'm trying to select with RegEx the manually selected line (from PHOTO to the \n before REV) but PHOTO(?s)(.*)REV - RegEx which selects that line when the depicted content is utilized at https://regex101.com./# - is considered invalid by VSC.

Screenshot_20240617_235658

Apologies if that explanation is not what you request.

IllusionMH commented 2 months ago

Regexp101 also shows an error if you switch to ES/JS image Editor's find widget uses ES/JS engine and its grammar, as mentioned above, and correctly report issue with your pattern.

PCRE is used only for global search and in you don't have file open, open files switch to JS

RokeJulianLockhart commented 2 months ago

https://github.com/microsoft/vscode/issues/216105#issuecomment-2343057920

@IllusionMH, so I should the issue as unactionable? Would be nice if the dialogue demonstrated which engine it was using for a given operation.