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 CompileRegex not actually setting a valid error code. #775

Merged
merged 2 commits into from
May 28, 2018

Conversation

Drifter321
Copy link
Member

CompileRegex is currently setting the error code to the offset of where the error occurred rather than the actual error.

To fix this pcre_compile was replaced with pcre_compile2 and a map used to convert the pcre error to a simpler (posix) error code but maintaining pcre's error string and adding the error codes to the enum. Also changed the internal member names since it was rather confusing. In the future we can also add in the offset so we can pass the offset where the error occurred.

The reason for mapping the errors is that pcre's error codes dont seem to be documented at all(?) From pcre_internal.h the errors are named ERR0, ERR1 etc... and i couldn't find any more information. There is also over 80 of them (due to the amount of detail) so I think the posix error codes are a simpler approach.

Small test plugin and its output.

public void OnPluginStart()
{
	char test_string[] = "my9_test1+string2.wooooo5";
	
	RegexError errorcode;
	char error[128]

	Regex re = new Regex("([^_|\\\\][a-zA-z|+])([0-9]", _, error, sizeof(error), errorcode);
	
	PrintToServer("Error code is %i (%s)", view_as<int>(errorcode), error);
}

Error code is 11 (missing ))

@Drifter321 Drifter321 merged commit d430bd2 into master May 28, 2018
@Headline Headline deleted the regex-compile-fix branch July 31, 2018 21:47
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

3 participants