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

Regex match pattern in SteamTools.psm1 misses matches #12

Open
ciphernemo opened this issue Dec 21, 2024 · 1 comment
Open

Regex match pattern in SteamTools.psm1 misses matches #12

ciphernemo opened this issue Dec 21, 2024 · 1 comment

Comments

@ciphernemo
Copy link

In the ConvertFrom-VDF function of the SteamTools.psm1 file on line 43, the regular expression (?<=")([^\"\t\s]+\s?)+(?=") doesn't account for escaped double quote marks (\") inside a quoted element. Steam is able to escape double quote marks when reading and writing to VDF files. If a quoted element has escaped double quotes, this function will fail to add that element.

A vdf with the following app section will not have the LaunchOptions object added via the Add-Member command. Example within "Software" { "Valve" { "Steam" { "apps" { ...

"1111111"
{
	"LastPlayed"		"1111111111"
	"BadgeData"		"11111111111"
	"Playtime2wks"		"1111"
	"Playtime"		"1111"
	"LaunchOptions"		"\"C:\some folder\some batch file.bat\" %command%"
}

Thanks!

@ciphernemo
Copy link
Author

I've reworked both the ConvertFrom-VDF and CovnertTo-VDF functions within SteamTools.psm1 to better work with VDFs and will put in a pull request for this. I've been struggling with the regular expression but finally got it working well. I had to change the CovnertTo-VDF function completely to use one for loop instead of the multiple foreach loops since foreach does not retain the order we originally used in CovnertFrom-VDF. Now a config file converts to a PSCustomObject and then back to a VDF perfectly, without any data loss or order changes. I ran file comparisons and they're identical now.

New regular expression in ConvertFrom-VDF: (?<=^|\t|{|\n)"((?:[^"\\]|\[\"])*)"(?=\t|\n|$|})

I originally wanted to remove the quote marks on each member name, but realized two things: 1.) we should leave them there for safety reasons, and 2.) leaving them means a much less complex regular expression (it was twice as long to remove them).

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

1 participant