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

revert regex related linting #24

Merged
merged 1 commit into from
Jul 13, 2021
Merged

revert regex related linting #24

merged 1 commit into from
Jul 13, 2021

Conversation

ysugimoto
Copy link
Owner

My apologies that Varnish regular expression is not compatible for Golang's regexp package.

It causes:

if (req.url ~ "^/([^\?]*)?(\?.*)?$") {
...
}

Then raises [ERROR] regex string is invalid, error parsing regexp: invalid or unsupported Perl syntax: (?.
I assume that VCL regular expression is using Perl syntax but Golang does not have it... so I revert these changes 😢

@ysugimoto ysugimoto requested a review from smaeda-ks July 13, 2021 04:49
@ysugimoto ysugimoto merged commit eca40c4 into main Jul 13, 2021
@ysugimoto ysugimoto deleted the revert-regex-check branch July 13, 2021 04:52
@ysugimoto
Copy link
Owner Author

Temporary revert this change. I guess it may fix by escaping back-slash.
"^/([^\?]*)?(\?.*)?$" does not seem Perl syntax, just matches ? character 🤔

@smaeda-ks
Copy link
Collaborator

I think you're right. Can regexp.QuoteMeta help here?
https://pkg.go.dev/regexp#QuoteMeta

@ysugimoto
Copy link
Owner Author

Thanks, I think that function also escapes other meta characters like [.
Simply we can replace escape back-slack like strings.ReplaceAll(regexString, "\\", "\\\\").

@smaeda-ks
Copy link
Collaborator

Ah, I misunderstood the point. Sounds good.

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.

2 participants