Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extension doesn't load selected regular expressions in view #1

Closed
anothermh opened this issue Apr 4, 2023 · 4 comments
Closed

Extension doesn't load selected regular expressions in view #1

anothermh opened this issue Apr 4, 2023 · 4 comments

Comments

@anothermh
Copy link

Steps to reproduce:

  1. Highlight a regex
  2. Right-click and select RegExp Visualize
  3. Web view appears but does not have the expression and does not render a view

Screenshot 2023-04-04 at 12 26 11 PM

Entering any expression doesn't cause the expression to load a visualization. It remains blank.

@yubaoquan
Copy link
Owner

what is the content of your regex? open the devTool of vscode with Help>Toggle Developer Tools, is there any error in console?

@anothermh
Copy link
Author

anothermh commented Apr 6, 2023

The content is for example ^(foo|bar|baz)$. For that regex here is the console output:

console.ts:137 [Extension Host] ^(foo|bar|baz)$

VM11:236 Uncaught SyntaxError: Unexpected string
    at index.html?id=a67bba0b-652a-4335-b620-ebcb1b49a7ee&origin=fafcb746-10a5-4f4b-8a9d-1be1230e42d4&swVersion=4&extensionId=ybq.reg-visualizer&platform=electron&vscode-resource-base-authority=vscode-resource.vscode-cdn.net&parentOrigin=vscode-file%3A%2F%2Fvscode-app:980:23
(anonymous) @ index.html?id=a67bba0b-652a-4335-b620-ebcb1b49a7ee&origin=fafcb746-10a5-4f4b-8a9d-1be1230e42d4&swVersion=4&extensionId=ybq.reg-visualizer&platform=electron&vscode-resource-base-authority=vscode-resource.vscode-cdn.net&parentOrigin=vscode-file%3A%2F%2Fvscode-app:980
setTimeout (async)
onFrameLoaded @ index.html?id=a67bba0b-652a-4335-b620-ebcb1b49a7ee&origin=fafcb746-10a5-4f4b-8a9d-1be1230e42d4&swVersion=4&extensionId=ybq.reg-visualizer&platform=electron&vscode-resource-base-authority=vscode-resource.vscode-cdn.net&parentOrigin=vscode-file%3A%2F%2Fvscode-app:978
(anonymous) @ index.html?id=a67bba0b-652a-4335-b620-ebcb1b49a7ee&origin=fafcb746-10a5-4f4b-8a9d-1be1230e42d4&swVersion=4&extensionId=ybq.reg-visualizer&platform=electron&vscode-resource-base-authority=vscode-resource.vscode-cdn.net&parentOrigin=vscode-file%3A%2F%2Fvscode-app:1009

VM12:1 Uncaught SyntaxError: Unexpected token ','
    at index.html?id=a67bba0b-652a-4335-b620-ebcb1b49a7ee&origin=fafcb746-10a5-4f4b-8a9d-1be1230e42d4&swVersion=4&extensionId=ybq.reg-visualizer&platform=electron&vscode-resource-base-authority=vscode-resource.vscode-cdn.net&parentOrigin=vscode-file%3A%2F%2Fvscode-app:980:23
(anonymous) @ index.html?id=a67bba0b-652a-4335-b620-ebcb1b49a7ee&origin=fafcb746-10a5-4f4b-8a9d-1be1230e42d4&swVersion=4&extensionId=ybq.reg-visualizer&platform=electron&vscode-resource-base-authority=vscode-resource.vscode-cdn.net&parentOrigin=vscode-file%3A%2F%2Fvscode-app:980
setTimeout (async)
onFrameLoaded @ index.html?id=a67bba0b-652a-4335-b620-ebcb1b49a7ee&origin=fafcb746-10a5-4f4b-8a9d-1be1230e42d4&swVersion=4&extensionId=ybq.reg-visualizer&platform=electron&vscode-resource-base-authority=vscode-resource.vscode-cdn.net&parentOrigin=vscode-file%3A%2F%2Fvscode-app:978
(anonymous) @ index.html?id=a67bba0b-652a-4335-b620-ebcb1b49a7ee&origin=fafcb746-10a5-4f4b-8a9d-1be1230e42d4&swVersion=4&extensionId=ybq.reg-visualizer&platform=electron&vscode-resource-base-authority=vscode-resource.vscode-cdn.net&parentOrigin=vscode-file%3A%2F%2Fvscode-app:1009

Clicking VM11:236 shows the problem at the top of the source file in params:

/* eslint-disable no-restricted-globals, no-alert, global-require */
/* globals document, window */

const params = {
  embed: false,
  re: `^(foo|bar|baz)<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>Regulex:JavaScript Regular Expression Visualizer</title>
    <style>body,
html * {
  margin: 0;
  padding: 0;
  font-family: sans-serif;
}

This error causes the webview that it loads to be unusable. If I close the webview and then type a simple string like foo and then right-click and visualize it then the webview loads properly:

Screenshot 2023-04-06 at 11 46 49 AM

I can then manually enter my original regex ^(foo|bar|baz)$ into this webview and it renders properly, because params was not malformed when it was generated:

Screenshot 2023-04-06 at 11 47 04 AM

The problem is likely that the $ is likely not being escaped somewhere. Any regex including $ appears to break the webview if it is present when the webview is generated.

@yubaoquan
Copy link
Owner

The problem is likely that the $ is likely not being escaped somewhere. Any regex including $ appears to break the webview if it is present when the webview is generated.

Yes you are right. I fixed it now. Upgrade to version 0.0.2 please. Tell me if the issue still exists.
Thank you for your help. :)

@anothermh
Copy link
Author

Works great, thank you.

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

No branches or pull requests

2 participants