lenilsondc / vbspretty

VBScript parser and beautifier as a node module
MIT License
5 stars 2 forks source link

2 or 4 consecutive double-quotes ("""") are treated as strings and are now separated by a unintended space #1

Closed pravynandas closed 3 years ago

pravynandas commented 3 years ago

'======= Example 1 ============= buf.Add buf.Count, """"

Now became

buf.Add buf.Count, "" "" '======= Example 2 ============= Case """"

became

Case "" "" '======= Example 3 ============= Set StringChunk = New RegExp StringChunk.Pattern = "([\s\S]*?)([""\\x00-\x1f])"

became

Set StringChunk = New RegExp StringChunk.Pattern = "([\s\S]*?)([" "\\x00-\x1f])"

pravynandas commented 3 years ago

parsed.json value & type

image

Final output with unintended space

image

pravynandas commented 3 years ago

Applied a fix to join any two consecutive STRING types into one STRING. Result is positive.

image

Will create a PR in a moment.

lenilsondc commented 3 years ago

I'll have a look into it.

lenilsondc commented 3 years ago

The problem is the double quotes "" in vbscript means an escaped quote like \" in other languages; therefore, it shouldn't even be parsed in a separate string but on single string.

Dim test : test = "double quotes ("") is an escaped quote in vbscript"
lenilsondc commented 3 years ago

I'll provide a fix.

lenilsondc commented 3 years ago

Done, latest commit addresses this issue. Can you confirm it's working on your tests?

pravynandas commented 3 years ago

Fix working great. Thanks.

I closed the PR I created, since is no more needed. For now published new version on @vbsnext/vbs-pretty at npmjs. But as soon as your primary package available, I will start using it.

lenilsondc commented 3 years ago

@pravynandas There it goes https://www.npmjs.com/package/vbspretty

pravynandas commented 3 years ago

Awesome @lenilsondc . I used the package and is working great. @vbsnext/vbs-pretty is now obsolete and is deleted.