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

Fix for infinite loop in Replacing Tokens when property values contain the Regex special char "$" #777

Merged
merged 1 commit into from
Nov 7, 2022

Conversation

Autophanous
Copy link
Contributor

@Autophanous Autophanous commented Oct 25, 2022

The current implementation only escapes property values containing "$0" and will not escape other Regex $ expressions (e.g. "$", "$1", "$2").
These unescaped Regex $ expressions will be replaced with the whole match value and cause an infinite loop.

Doing property.Value.Replace("$", "$$") ensures all $ chars are properly escaped from the property value.

E.g.
property.Value = "with a market value estimated to be worth $ 50 billion by 2025" will be replaced by "with a market value estimated to be worth with a market value estimated to be worth $ 50 billion by 2025 50 billion by 2025"

The current implementation only escapes "$0" and will not escape other Regex $ expressions (e.g. "$", "$1", "$2")
Doing property.Value.Replace("$", "$$") ensures all $ chars are escaped from property value.
@Autophanous Autophanous changed the title Should escape Regex especial char "$" instead of "$0" Fix for infinite loop in Replacing Tokens when property values contain Regex special char "$" Oct 26, 2022
@Autophanous Autophanous changed the title Fix for infinite loop in Replacing Tokens when property values contain Regex special char "$" Fix for infinite loop in Replacing Tokens when property values contain the Regex special char "$" Oct 26, 2022
jansenbe added a commit that referenced this pull request Nov 7, 2022
@jansenbe jansenbe merged commit a033c17 into pnp:dev Nov 7, 2022
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

Successfully merging this pull request may close these issues.

None yet

2 participants