MCPcopy Create free account
hub / github.com/M66B/FairEmail / is8Bit

Method is8Bit

app/src/main/java/com/sun/mail/smtp/SMTPTransport.java:1672–1697  ·  view source on GitHub ↗

Check whether the data in the given InputStream follows the rules for 8bit text. Lines have to be 998 characters or less and no NULs are allowed. CR and LF must occur in pairs but we don't check that because we assume this is text and we convert all CR/LF combinations into canonical CRLF later.

(InputStream is)

Source from the content-addressed store, hash-verified

1670 * all CR/LF combinations into canonical CRLF later.
1671 */
1672 private boolean is8Bit(InputStream is) {
1673 int b;
1674 int linelen = 0;
1675 boolean need8bit = false;
1676 try {
1677 while ((b = is.read()) >= 0) {
1678 b &= 0xff;
1679 if (b == '\r' || b == '\n')
1680 linelen = 0;
1681 else if (b == 0)
1682 return false;
1683 else {
1684 linelen++;
1685 if (linelen > 998) // 1000 - CRLF
1686 return false;
1687 }
1688 if (b > 0x7f)
1689 need8bit = true;
1690 }
1691 } catch (IOException ex) {
1692 return false;
1693 }
1694 if (need8bit)
1695 logger.fine("found an 8bit part");
1696 return need8bit;
1697 }
1698
1699 @Override
1700 protected void finalize() throws Throwable {

Callers 1

convertTo8BitMethod · 0.95

Calls 2

fineMethod · 0.80
readMethod · 0.45

Tested by

no test coverage detected