We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
In WindowsPrintConnector, the regex below breaks on PHP 7.3, which made some changes to how preg_match works.
The error is
WindowsPrintConnector.php Line:126 "preg_match(): Compilation failed: invalid range in character class at offset 29"
The regex is:
const REGEX_SMB = "/^smb:\/\/([\s\d\w-]+(:[\s\d\w-+]+)?@)?([\d\w-]+\.)*[\d\w-]+\/([\d\w-]+\/)?[\d\w-]+(\s[\d\w-]+)*$/";
According to https://www.debuggex.com/, the issue is with the second pattern
(:[\s\d\w-+]+)
I am not an expert with regex, but I find it works if the dash is removed
(:[\s\d\w+]+)
I believe this regex was changed to add the interior plus sign in
#392
The text was updated successfully, but these errors were encountered:
I have been able to replicate this on PHP 7.3 (the unit tests catch it), so let's call it a bug. Thanks for reporting.
Unfortunately I think your change would reject lots of valid printer names, so let's keep thinking.
/** * Test for correct identification of bogus or non-supported Samba strings. */ public function testSambaRegex() { $good = array("smb://foo/bar", "smb://foo/bar baz", "smb://bob@foo/bar", "smb://bob:secret@foo/bar", "smb://foo-computer/FooPrinter", "smb://foo-computer/workgroup/FooPrinter", "smb://foo-computer/Foo-Printer", "smb://foo-computer/workgroup/Foo-Printer", "smb://foo-computer/Foo Printer", "smb://foo-computer.local/Foo Printer", "smb://127.0.0.1/abcd" ); $bad = array("", "http://google.com", "smb:/foo/bar", "smb://", "smb:///bar", "smb://@foo/bar", "smb://bob:@foo/bar", "smb://:secret@foo/bar", "smb://foo/bar/baz/quux", "smb://foo-computer//FooPrinter"); foreach ($good as $item) { $this -> assertTrue(preg_match(WindowsPrintConnector::REGEX_SMB, $item) == 1, "Windows samba regex should pass '$item'."); } foreach ($bad as $item) { $this -> assertTrue(preg_match(WindowsPrintConnector::REGEX_SMB, $item) != 1, "Windows samba regex should fail '$item'."); } }
Sorry, something went wrong.
This fix has been released in v2.1 today.
No branches or pull requests
In WindowsPrintConnector, the regex below breaks on PHP 7.3, which made some changes to how preg_match works.
The error is
WindowsPrintConnector.php Line:126 "preg_match(): Compilation failed: invalid range in character class at offset 29"
The regex is:
const REGEX_SMB = "/^smb:\/\/([\s\d\w-]+(:[\s\d\w-+]+)?@)?([\d\w-]+\.)*[\d\w-]+\/([\d\w-]+\/)?[\d\w-]+(\s[\d\w-]+)*$/";
According to https://www.debuggex.com/, the issue is with the second pattern
(:[\s\d\w-+]+)
I am not an expert with regex, but I find it works if the dash is removed
(:[\s\d\w+]+)
I believe this regex was changed to add the interior plus sign in
#392
The text was updated successfully, but these errors were encountered: