You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Dec 10, 2018. It is now read-only.
This bug is for qz-print versions 1.9.x and older (1.8.0 included) and breaks printer searching for search parameters containing backslash E(\E or JavaScript "\\E" also "\\\\E").
Example
If a printer shared on a Windows or Samba network with "E" as part of the host name, for example:
\\Elephant\printer
And you perform a search like this:
findPrinter("\\\\Elephant\\printer");
You will receive the following exception:
Exception in thread "Thread-26" java.util.regex.PatternSyntaxException: Illegal/unsupported escape sequence near index x ...
\b\Q\\Elephant\printer\E\b
^
This is caused by the special RegEx character \E being used within a Pattern match.
Work-around 1 Replace uppercase \E with lowercase \e:
findPrinter(printerName.toLowerCase());
Reason
\e is not a reserved character, which allows printer searching to succeed
Work-around 2 Perform JavaRegex pattern escaping:
if (printerName.indexOf("\E") != -1) {
printerName = printerName.replace(/\\E/, "\\E\\\\E\\Q");
}
Reason
This complicated combination of E's and Q's is the proper escaping technique and is a work-around until the applet is written to do this automatically
@bberenz can we revisit this bug for 2.0? There's really no advantage in using RegEx in my opinion as programmers can do that client-side if they wish.
Can you clarify how you want findPrinter to work in that case?
It seems like you want the method to return a PrintService for exact matches on the name string, and partial matches will be handled client side only from searching the printer list.
This bug is for qz-print versions 1.9.x and older (1.8.0 included) and breaks printer searching for search parameters containing
backslash E
(\E
or JavaScript"\\E"
also"\\\\E"
).Example
If a printer shared on a Windows or Samba network with "E" as part of the host name, for example:
And you perform a search like this:
You will receive the following exception:
This is caused by the special RegEx character
\E
being used within a Pattern match.Work-around 1
Replace uppercase
\E
with lowercase\e
:Reason
Work-around 2
Perform JavaRegex pattern escaping:
Reason
More information on these E's and Q's here:
Permanent Fix
The long term fix to this is to use
Pattern.quote(printerName);
internal to the applet, which will be corrected with 2.0.0.-Tres
The text was updated successfully, but these errors were encountered: