Added: websites/production/commons/content/proper/commons-fileupload/jacoco/org.apache.commons.fileupload.util.mime/MimeUtility.java.html ============================================================================== --- websites/production/commons/content/proper/commons-fileupload/jacoco/org.apache.commons.fileupload.util.mime/MimeUtility.java.html (added) +++ websites/production/commons/content/proper/commons-fileupload/jacoco/org.apache.commons.fileupload.util.mime/MimeUtility.java.html Mon Feb 13 10:43:35 2023 @@ -0,0 +1,284 @@ +<?xml version="1.0" encoding="iso-8859-1"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>MimeUtility.java</title><link rel="stylesheet" href="../jacoco-resources/prettify.css" type="text/css"/><script type="text/javascript" src="../jacoco-resources/prettify.js"></script></head><body onload="window['PR_TAB_WIDTH']=4;prettyPrint()"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">Apache Commons FileUpload</a> > <a href="index.source.html" class="el_package">org.apache.commons.fileupload.util.mime</a> > <span class="el_source">MimeUtility.java</span></div><h1>MimeUtility.java</h1><pre class="source lang-java linenums">/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.commons.fileupload.util.mime; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.UnsupportedEncodingException; +import java.util.HashMap; +import java.util.Locale; +import java.util.Map; + +/** + * Utility class to decode MIME texts. + * + * @since 1.3 + */ +public final class MimeUtility { + + /** + * The {@code US-ASCII} charset identifier constant. + */ + private static final String US_ASCII_CHARSET = "US-ASCII"; + + /** + * The marker to indicate text is encoded with BASE64 algorithm. + */ + private static final String BASE64_ENCODING_MARKER = "B"; + + /** + * The marker to indicate text is encoded with QuotedPrintable algorithm. + */ + private static final String QUOTEDPRINTABLE_ENCODING_MARKER = "Q"; + + /** + * If the text contains any encoded tokens, those tokens will be marked with "=?". + */ + private static final String ENCODED_TOKEN_MARKER = "=?"; + + /** + * If the text contains any encoded tokens, those tokens will terminate with "=?". + */ + private static final String ENCODED_TOKEN_FINISHER = "?="; + + /** + * The linear whitespace chars sequence. + */ + private static final String LINEAR_WHITESPACE = " \t\r\n"; + + /** + * Mappings between MIME and Java charset. + */ +<span class="fc" id="L66"> private static final Map<String, String> MIME2JAVA = new HashMap<String, String>();</span> + + static { +<span class="fc" id="L69"> MIME2JAVA.put("iso-2022-cn", "ISO2022CN");</span> +<span class="fc" id="L70"> MIME2JAVA.put("iso-2022-kr", "ISO2022KR");</span> +<span class="fc" id="L71"> MIME2JAVA.put("utf-8", "UTF8");</span> +<span class="fc" id="L72"> MIME2JAVA.put("utf8", "UTF8");</span> +<span class="fc" id="L73"> MIME2JAVA.put("ja_jp.iso2022-7", "ISO2022JP");</span> +<span class="fc" id="L74"> MIME2JAVA.put("ja_jp.eucjp", "EUCJIS");</span> +<span class="fc" id="L75"> MIME2JAVA.put("euc-kr", "KSC5601");</span> +<span class="fc" id="L76"> MIME2JAVA.put("euckr", "KSC5601");</span> +<span class="fc" id="L77"> MIME2JAVA.put("us-ascii", "ISO-8859-1");</span> +<span class="fc" id="L78"> MIME2JAVA.put("x-us-ascii", "ISO-8859-1");</span> +<span class="fc" id="L79"> }</span> + + /** + * Hidden constructor, this class must not be instantiated. + */ + private MimeUtility() { + // do nothing + } + + /** + * Decode a string of text obtained from a mail header into + * its proper form. The text generally will consist of a + * string of tokens, some of which may be encoded using + * base64 encoding. + * + * @param text The text to decode. + * + * @return The decoded text string. + * @throws UnsupportedEncodingException if the detected encoding in the input text is not supported. + */ + public static String decodeText(String text) throws UnsupportedEncodingException { + // if the text contains any encoded tokens, those tokens will be marked with "=?". If the + // source string doesn't contain that sequent, no decoding is required. +<span class="fc bfc" id="L102" title="All 2 branches covered."> if (text.indexOf(ENCODED_TOKEN_MARKER) < 0) {</span> +<span class="fc" id="L103"> return text;</span> + } + +<span class="fc" id="L106"> int offset = 0;</span> +<span class="fc" id="L107"> int endOffset = text.length();</span> + +<span class="fc" id="L109"> int startWhiteSpace = -1;</span> +<span class="fc" id="L110"> int endWhiteSpace = -1;</span> + +<span class="fc" id="L112"> StringBuilder decodedText = new StringBuilder(text.length());</span> + +<span class="fc" id="L114"> boolean previousTokenEncoded = false;</span> + +<span class="fc bfc" id="L116" title="All 2 branches covered."> while (offset < endOffset) {</span> +<span class="fc" id="L117"> char ch = text.charAt(offset);</span> + + // is this a whitespace character? +<span class="fc bfc" id="L120" title="All 2 branches covered."> if (LINEAR_WHITESPACE.indexOf(ch) != -1) { // whitespace found</span> +<span class="fc" id="L121"> startWhiteSpace = offset;</span> +<span class="fc bfc" id="L122" title="All 2 branches covered."> while (offset < endOffset) {</span> + // step over the white space characters. +<span class="fc" id="L124"> ch = text.charAt(offset);</span> +<span class="fc bfc" id="L125" title="All 2 branches covered."> if (LINEAR_WHITESPACE.indexOf(ch) != -1) { // whitespace found</span> +<span class="fc" id="L126"> offset++;</span> + } else { + // record the location of the first non lwsp and drop down to process the + // token characters. +<span class="fc" id="L130"> endWhiteSpace = offset;</span> +<span class="fc" id="L131"> break;</span> + } + } + } else { + // we have a word token. We need to scan over the word and then try to parse it. +<span class="fc" id="L136"> int wordStart = offset;</span> + +<span class="fc bfc" id="L138" title="All 2 branches covered."> while (offset < endOffset) {</span> + // step over the non white space characters. +<span class="fc" id="L140"> ch = text.charAt(offset);</span> +<span class="fc bfc" id="L141" title="All 2 branches covered."> if (LINEAR_WHITESPACE.indexOf(ch) == -1) { // not white space</span> +<span class="fc" id="L142"> offset++;</span> + } else { + break; + } + + //NB: Trailing whitespace on these header strings will just be discarded. + } + // pull out the word token. +<span class="fc" id="L150"> String word = text.substring(wordStart, offset);</span> + // is the token encoded? decode the word +<span class="pc bpc" id="L152" title="1 of 2 branches missed."> if (word.startsWith(ENCODED_TOKEN_MARKER)) {</span> + try { + // if this gives a parsing failure, treat it like a non-encoded word. +<span class="fc" id="L155"> String decodedWord = decodeWord(word);</span> + + // are any whitespace characters significant? Append 'em if we've got 'em. +<span class="pc bpc" id="L158" title="1 of 4 branches missed."> if (!previousTokenEncoded && startWhiteSpace != -1) {</span> +<span class="nc" id="L159"> decodedText.append(text.substring(startWhiteSpace, endWhiteSpace));</span> +<span class="nc" id="L160"> startWhiteSpace = -1;</span> + } + // this is definitely a decoded token. +<span class="fc" id="L163"> previousTokenEncoded = true;</span> + // and add this to the text. +<span class="fc" id="L165"> decodedText.append(decodedWord);</span> + // we continue parsing from here...we allow parsing errors to fall through + // and get handled as normal text. +<span class="fc" id="L168"> continue;</span> + +<span class="nc" id="L170"> } catch (ParseException e) {</span> + // just ignore it, skip to next word + } + } + // this is a normal token, so it doesn't matter what the previous token was. Add the white space + // if we have it. +<span class="nc bnc" id="L176" title="All 2 branches missed."> if (startWhiteSpace != -1) {</span> +<span class="nc" id="L177"> decodedText.append(text.substring(startWhiteSpace, endWhiteSpace));</span> +<span class="nc" id="L178"> startWhiteSpace = -1;</span> + } + // this is not a decoded token. +<span class="nc" id="L181"> previousTokenEncoded = false;</span> +<span class="nc" id="L182"> decodedText.append(word);</span> + } +<span class="fc" id="L184"> }</span> + +<span class="fc" id="L186"> return decodedText.toString();</span> + } + + /** + * Parse a string using the RFC 2047 rules for an "encoded-word" + * type. This encoding has the syntax: + * + * encoded-word = "=?" charset "?" encoding "?" encoded-text "?=" + * + * @param word The possibly encoded word value. + * + * @return The decoded word. + * @throws ParseException + * @throws UnsupportedEncodingException + */ + private static String decodeWord(String word) throws ParseException, UnsupportedEncodingException { + // encoded words start with the characters "=?". If this not an encoded word, we throw a + // ParseException for the caller. + +<span class="pc bpc" id="L205" title="1 of 2 branches missed."> if (!word.startsWith(ENCODED_TOKEN_MARKER)) {</span> +<span class="nc" id="L206"> throw new ParseException("Invalid RFC 2047 encoded-word: " + word);</span> + } + +<span class="fc" id="L209"> int charsetPos = word.indexOf('?', 2);</span> +<span class="pc bpc" id="L210" title="1 of 2 branches missed."> if (charsetPos == -1) {</span> +<span class="nc" id="L211"> throw new ParseException("Missing charset in RFC 2047 encoded-word: " + word);</span> + } + + // pull out the character set information (this is the MIME name at this point). +<span class="fc" id="L215"> String charset = word.substring(2, charsetPos).toLowerCase(Locale.ENGLISH);</span> + + // now pull out the encoding token the same way. +<span class="fc" id="L218"> int encodingPos = word.indexOf('?', charsetPos + 1);</span> +<span class="pc bpc" id="L219" title="1 of 2 branches missed."> if (encodingPos == -1) {</span> +<span class="nc" id="L220"> throw new ParseException("Missing encoding in RFC 2047 encoded-word: " + word);</span> + } + +<span class="fc" id="L223"> String encoding = word.substring(charsetPos + 1, encodingPos);</span> + + // and finally the encoded text. +<span class="fc" id="L226"> int encodedTextPos = word.indexOf(ENCODED_TOKEN_FINISHER, encodingPos + 1);</span> +<span class="pc bpc" id="L227" title="1 of 2 branches missed."> if (encodedTextPos == -1) {</span> +<span class="nc" id="L228"> throw new ParseException("Missing encoded text in RFC 2047 encoded-word: " + word);</span> + } + +<span class="fc" id="L231"> String encodedText = word.substring(encodingPos + 1, encodedTextPos);</span> + + // seems a bit silly to encode a null string, but easy to deal with. +<span class="pc bpc" id="L234" title="1 of 2 branches missed."> if (encodedText.length() == 0) {</span> +<span class="nc" id="L235"> return "";</span> + } + + try { + // the decoder writes directly to an output stream. +<span class="fc" id="L240"> ByteArrayOutputStream out = new ByteArrayOutputStream(encodedText.length());</span> + +<span class="fc" id="L242"> byte[] encodedData = encodedText.getBytes(US_ASCII_CHARSET);</span> + + // Base64 encoded? +<span class="fc bfc" id="L245" title="All 2 branches covered."> if (encoding.equals(BASE64_ENCODING_MARKER)) {</span> +<span class="fc" id="L246"> Base64Decoder.decode(encodedData, out);</span> +<span class="pc bpc" id="L247" title="1 of 2 branches missed."> } else if (encoding.equals(QUOTEDPRINTABLE_ENCODING_MARKER)) { // maybe quoted printable.</span> +<span class="fc" id="L248"> QuotedPrintableDecoder.decode(encodedData, out);</span> + } else { +<span class="nc" id="L250"> throw new UnsupportedEncodingException("Unknown RFC 2047 encoding: " + encoding);</span> + } + // get the decoded byte data and convert into a string. +<span class="fc" id="L253"> byte[] decodedData = out.toByteArray();</span> +<span class="fc" id="L254"> return new String(decodedData, javaCharset(charset));</span> +<span class="fc" id="L255"> } catch (IOException e) {</span> +<span class="fc" id="L256"> throw new UnsupportedEncodingException("Invalid RFC 2047 encoding");</span> + } + } + + /** + * Translate a MIME standard character set name into the Java + * equivalent. + * + * @param charset The MIME standard name. + * + * @return The Java equivalent for this name. + */ + private static String javaCharset(String charset) { + // nothing in, nothing out. +<span class="pc bpc" id="L270" title="1 of 2 branches missed."> if (charset == null) {</span> +<span class="nc" id="L271"> return null;</span> + } + +<span class="fc" id="L274"> String mappedCharset = MIME2JAVA.get(charset.toLowerCase(Locale.ENGLISH));</span> + // if there is no mapping, then the original name is used. Many of the MIME character set + // names map directly back into Java. The reverse isn't necessarily true. +<span class="fc bfc" id="L277" title="All 2 branches covered."> if (mappedCharset == null) {</span> +<span class="fc" id="L278"> return charset;</span> + } +<span class="fc" id="L280"> return mappedCharset;</span> + } + +} +</pre><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.8.202204050719</span></div></body></html> \ No newline at end of file
Added: websites/production/commons/content/proper/commons-fileupload/jacoco/org.apache.commons.fileupload.util.mime/ParseException.html ============================================================================== --- websites/production/commons/content/proper/commons-fileupload/jacoco/org.apache.commons.fileupload.util.mime/ParseException.html (added) +++ websites/production/commons/content/proper/commons-fileupload/jacoco/org.apache.commons.fileupload.util.mime/ParseException.html Mon Feb 13 10:43:35 2023 @@ -0,0 +1 @@ +<?xml version="1.0" encoding="iso-8859-1"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>ParseException</title><script type="text/javascript" src="../jacoco-resources/sort.js"></script></head><body onload="initialSort(['breadcrumb'])"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">Apache Commons FileUpload</a> > <a href="index.html" class="el_package">org.apache.commons.fileupload.util.mime</a> > <span class="el_class">ParseException</span></div><h1>ParseException</h1><table class="coverage" cellspacing= "0" id="coveragetable"><thead><tr><td class="sortable" id="a" onclick="toggleSort(this)">Element</td><td class="down sortable bar" id="b" onclick="toggleSort(this)">Missed Instructions</td><td class="sortable ctr2" id="c" onclick="toggleSort(this)">Cov.</td><td class="sortable bar" id="d" onclick="toggleSort(this)">Missed Branches</td><td class="sortable ctr2" id="e" onclick="toggleSort(this)">Cov.</td><td class="sortable ctr1" id="f" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="g" onclick="toggleSort(this)">Cxty</td><td class="sortable ctr1" id="h" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="i" onclick="toggleSort(this)">Lines</td><td class="sortable ctr1" id="j" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="k" onclick="toggleSort(this)">Methods</td></tr></thead><tfoot><tr><td>Total</td><td class="bar">4 of 4</td><td class="ctr2">0%</td><td class="bar">0 of 0</td><td class="ctr2">n/a</td><td class="ctr1">1</td><td class="ctr2">1</td><td class="ctr1">2</td><td class="ctr2">2</td><td class="ctr1">1</td><td class="ctr2">1</td></tr></tfoot><tbody><tr><td id="a0"><a href="ParseException.java.html#L35" class="el_method">ParseException(String)</a></td><td class="bar" id="b0"><img src="../jacoco-resources/redbar.gif" width="120" height="10" title="4" alt="4"/></td><td class="ctr2" id="c0">0%</td><td class="bar" id="d0"/><td class="ctr2" id="e0">n/a</td><td class="ctr1" id="f0">1</td><td class="ctr2" id="g0">1</td><td class="ctr1" id="h0">2</td><td class="ctr2" id="i0">2</td><td class="ctr1" id="j0">1</td><td class="ctr2" id="k0">1</td></tr></tbody></table><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.8.202204050719</span></div></body></html> \ No newline at end of file Added: websites/production/commons/content/proper/commons-fileupload/jacoco/org.apache.commons.fileupload.util.mime/ParseException.java.html ============================================================================== --- websites/production/commons/content/proper/commons-fileupload/jacoco/org.apache.commons.fileupload.util.mime/ParseException.java.html (added) +++ websites/production/commons/content/proper/commons-fileupload/jacoco/org.apache.commons.fileupload.util.mime/ParseException.java.html Mon Feb 13 10:43:35 2023 @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="iso-8859-1"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>ParseException.java</title><link rel="stylesheet" href="../jacoco-resources/prettify.css" type="text/css"/><script type="text/javascript" src="../jacoco-resources/prettify.js"></script></head><body onload="window['PR_TAB_WIDTH']=4;prettyPrint()"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">Apache Commons FileUpload</a> > <a href="index.source.html" class="el_package">org.apache.commons.fileupload.util.mime</a> > <s pan class="el_source">ParseException.java</span></div><h1>ParseException.java</h1><pre class="source lang-java linenums">/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.commons.fileupload.util.mime; + +/** + * @since 1.3 + */ +final class ParseException extends Exception { + + /** + * The UID to use when serializing this instance. + */ + private static final long serialVersionUID = 5355281266579392077L; + + /** + * Constructs a new exception with the specified detail message. + * + * @param message the detail message. + */ + ParseException(String message) { +<span class="nc" id="L35"> super(message);</span> +<span class="nc" id="L36"> }</span> + +} +</pre><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.8.202204050719</span></div></body></html> \ No newline at end of file Added: websites/production/commons/content/proper/commons-fileupload/jacoco/org.apache.commons.fileupload.util.mime/QuotedPrintableDecoder.html ============================================================================== --- websites/production/commons/content/proper/commons-fileupload/jacoco/org.apache.commons.fileupload.util.mime/QuotedPrintableDecoder.html (added) +++ websites/production/commons/content/proper/commons-fileupload/jacoco/org.apache.commons.fileupload.util.mime/QuotedPrintableDecoder.html Mon Feb 13 10:43:35 2023 @@ -0,0 +1 @@ +<?xml version="1.0" encoding="iso-8859-1"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>QuotedPrintableDecoder</title><script type="text/javascript" src="../jacoco-resources/sort.js"></script></head><body onload="initialSort(['breadcrumb'])"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">Apache Commons FileUpload</a> > <a href="index.html" class="el_package">org.apache.commons.fileupload.util.mime</a> > <span class="el_class">QuotedPrintableDecoder</span></div><h1>QuotedPrintableDecoder</h1><table class ="coverage" cellspacing="0" id="coveragetable"><thead><tr><td class="sortable" id="a" onclick="toggleSort(this)">Element</td><td class="down sortable bar" id="b" onclick="toggleSort(this)">Missed Instructions</td><td class="sortable ctr2" id="c" onclick="toggleSort(this)">Cov.</td><td class="sortable bar" id="d" onclick="toggleSort(this)">Missed Branches</td><td class="sortable ctr2" id="e" onclick="toggleSort(this)">Cov.</td><td class="sortable ctr1" id="f" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="g" onclick="toggleSort(this)">Cxty</td><td class="sortable ctr1" id="h" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="i" onclick="toggleSort(this)">Lines</td><td class="sortable ctr1" id="j" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="k" onclick="toggleSort(this)">Methods</td></tr></thead><tfoot><tr><td>Total</td><td class="bar">0 of 104</td><td class="ctr2">100%</td><td class="bar">0 of 14</td><td class="ctr2">100%< /td><td class="ctr1">0</td><td class="ctr2">9</td><td class="ctr1">0</td><td class="ctr2">29</td><td class="ctr1">0</td><td class="ctr2">2</td></tr></tfoot><tbody><tr><td id="a0"><a href="QuotedPrintableDecoder.java.html#L50" class="el_method">decode(byte[], OutputStream)</a></td><td class="bar" id="b0"><img src="../jacoco-resources/greenbar.gif" width="120" height="10" title="82" alt="82"/></td><td class="ctr2" id="c0">100%</td><td class="bar" id="d0"><img src="../jacoco-resources/greenbar.gif" width="120" height="10" title="12" alt="12"/></td><td class="ctr2" id="e0">100%</td><td class="ctr1" id="f0">0</td><td class="ctr2" id="g0">7</td><td class="ctr1" id="h0">0</td><td class="ctr2" id="i0">25</td><td class="ctr1" id="j0">0</td><td class="ctr2" id="k0">1</td></tr><tr><td id="a1"><a href="QuotedPrintableDecoder.java.html#L105" class="el_method">hexToBinary(byte)</a></td><td class="bar" id="b1"><img src="../jacoco-resources/greenbar.gif" width="32" height="10" title="22" alt="22"/> </td><td class="ctr2" id="c1">100%</td><td class="bar" id="d1"><img src="../jacoco-resources/greenbar.gif" width="20" height="10" title="2" alt="2"/></td><td class="ctr2" id="e1">100%</td><td class="ctr1" id="f1">0</td><td class="ctr2" id="g1">2</td><td class="ctr1" id="h1">0</td><td class="ctr2" id="i1">4</td><td class="ctr1" id="j1">0</td><td class="ctr2" id="k1">1</td></tr></tbody></table><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.8.202204050719</span></div></body></html> \ No newline at end of file Added: websites/production/commons/content/proper/commons-fileupload/jacoco/org.apache.commons.fileupload.util.mime/QuotedPrintableDecoder.java.html ============================================================================== --- websites/production/commons/content/proper/commons-fileupload/jacoco/org.apache.commons.fileupload.util.mime/QuotedPrintableDecoder.java.html (added) +++ websites/production/commons/content/proper/commons-fileupload/jacoco/org.apache.commons.fileupload.util.mime/QuotedPrintableDecoder.java.html Mon Feb 13 10:43:35 2023 @@ -0,0 +1,113 @@ +<?xml version="1.0" encoding="iso-8859-1"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>QuotedPrintableDecoder.java</title><link rel="stylesheet" href="../jacoco-resources/prettify.css" type="text/css"/><script type="text/javascript" src="../jacoco-resources/prettify.js"></script></head><body onload="window['PR_TAB_WIDTH']=4;prettyPrint()"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">Apache Commons FileUpload</a> > <a href="index.source.html" class="el_package">org.apache.commons.fileupload.util.mime</a> > <span class="el_source">QuotedPrintableDecoder.java</span></div><h1>QuotedPrintableDecoder.java</h1><pre class="source lang-java linenums">/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.commons.fileupload.util.mime; + +import java.io.IOException; +import java.io.OutputStream; + +/** + * @since 1.3 + */ +final class QuotedPrintableDecoder { + + /** + * The shift value required to create the upper nibble + * from the first of 2 byte values converted from ascii hex. + */ + private static final int UPPER_NIBBLE_SHIFT = Byte.SIZE / 2; + + /** + * Hidden constructor, this class must not be instantiated. + */ + private QuotedPrintableDecoder() { + // do nothing + } + + /** + * Decode the encoded byte data writing it to the given output stream. + * + * @param data The array of byte data to decode. + * @param out The output stream used to return the decoded data. + * + * @return the number of bytes produced. + * @throws IOException + */ + public static int decode(byte[] data, OutputStream out) throws IOException { +<span class="fc" id="L50"> int off = 0;</span> +<span class="fc" id="L51"> int length = data.length;</span> +<span class="fc" id="L52"> int endOffset = off + length;</span> +<span class="fc" id="L53"> int bytesWritten = 0;</span> + +<span class="fc bfc" id="L55" title="All 2 branches covered."> while (off < endOffset) {</span> +<span class="fc" id="L56"> byte ch = data[off++];</span> + + // space characters were translated to '_' on encode, so we need to translate them back. +<span class="fc bfc" id="L59" title="All 2 branches covered."> if (ch == '_') {</span> +<span class="fc" id="L60"> out.write(' ');</span> +<span class="fc bfc" id="L61" title="All 2 branches covered."> } else if (ch == '=') {</span> + // we found an encoded character. Reduce the 3 char sequence to one. + // but first, make sure we have two characters to work with. +<span class="fc bfc" id="L64" title="All 2 branches covered."> if (off + 1 >= endOffset) {</span> +<span class="fc" id="L65"> throw new IOException("Invalid quoted printable encoding; truncated escape sequence");</span> + } + +<span class="fc" id="L68"> byte b1 = data[off++];</span> +<span class="fc" id="L69"> byte b2 = data[off++];</span> + + // we've found an encoded carriage return. The next char needs to be a newline +<span class="fc bfc" id="L72" title="All 2 branches covered."> if (b1 == '\r') {</span> +<span class="fc bfc" id="L73" title="All 2 branches covered."> if (b2 != '\n') {</span> +<span class="fc" id="L74"> throw new IOException("Invalid quoted printable encoding; CR must be followed by LF");</span> + } + // this was a soft linebreak inserted by the encoding. We just toss this away + // on decode. + } else { + // this is a hex pair we need to convert back to a single byte. +<span class="fc" id="L80"> int c1 = hexToBinary(b1);</span> +<span class="fc" id="L81"> int c2 = hexToBinary(b2);</span> +<span class="fc" id="L82"> out.write((c1 << UPPER_NIBBLE_SHIFT) | c2);</span> + // 3 bytes in, one byte out +<span class="fc" id="L84"> bytesWritten++;</span> + } +<span class="fc" id="L86"> } else {</span> + // simple character, just write it out. +<span class="fc" id="L88"> out.write(ch);</span> +<span class="fc" id="L89"> bytesWritten++;</span> + } +<span class="fc" id="L91"> }</span> + +<span class="fc" id="L93"> return bytesWritten;</span> + } + + /** + * Convert a hex digit to the binary value it represents. + * + * @param b the ascii hex byte to convert (0-0, A-F, a-f) + * @return the int value of the hex byte, 0-15 + * @throws IOException if the byte is not a valid hex digit. + */ + private static int hexToBinary(final byte b) throws IOException { + // CHECKSTYLE IGNORE MagicNumber FOR NEXT 1 LINE +<span class="fc" id="L105"> final int i = Character.digit((char) b, 16);</span> +<span class="fc bfc" id="L106" title="All 2 branches covered."> if (i == -1) {</span> +<span class="fc" id="L107"> throw new IOException("Invalid quoted printable encoding: not a valid hex digit: " + b);</span> + } +<span class="fc" id="L109"> return i;</span> + } + +} +</pre><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.8.202204050719</span></div></body></html> \ No newline at end of file Added: websites/production/commons/content/proper/commons-fileupload/jacoco/org.apache.commons.fileupload.util.mime/index.html ============================================================================== --- websites/production/commons/content/proper/commons-fileupload/jacoco/org.apache.commons.fileupload.util.mime/index.html (added) +++ websites/production/commons/content/proper/commons-fileupload/jacoco/org.apache.commons.fileupload.util.mime/index.html Mon Feb 13 10:43:35 2023 @@ -0,0 +1 @@ +<?xml version="1.0" encoding="iso-8859-1"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>org.apache.commons.fileupload.util.mime</title><script type="text/javascript" src="../jacoco-resources/sort.js"></script></head><body onload="initialSort(['breadcrumb', 'coveragetable'])"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="index.source.html" class="el_source">Source Files</a><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">Apache Commons FileUpload</a> > <span class="el_package">org.apache.commons.fileupload.util.mime</span></div><h1>org.apache.co mmons.fileupload.util.mime</h1><table class="coverage" cellspacing="0" id="coveragetable"><thead><tr><td class="sortable" id="a" onclick="toggleSort(this)">Element</td><td class="down sortable bar" id="b" onclick="toggleSort(this)">Missed Instructions</td><td class="sortable ctr2" id="c" onclick="toggleSort(this)">Cov.</td><td class="sortable bar" id="d" onclick="toggleSort(this)">Missed Branches</td><td class="sortable ctr2" id="e" onclick="toggleSort(this)">Cov.</td><td class="sortable ctr1" id="f" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="g" onclick="toggleSort(this)">Cxty</td><td class="sortable ctr1" id="h" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="i" onclick="toggleSort(this)">Lines</td><td class="sortable ctr1" id="j" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="k" onclick="toggleSort(this)">Methods</td><td class="sortable ctr1" id="l" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id= "m" onclick="toggleSort(this)">Classes</td></tr></thead><tfoot><tr><td>Total</td><td class="bar">96 of 884</td><td class="ctr2">89%</td><td class="bar">12 of 76</td><td class="ctr2">84%</td><td class="ctr1">12</td><td class="ctr2">47</td><td class="ctr1">17</td><td class="ctr2">153</td><td class="ctr1">1</td><td class="ctr2">9</td><td class="ctr1">1</td><td class="ctr2">4</td></tr></tfoot><tbody><tr><td id="a1"><a href="MimeUtility.html" class="el_class">MimeUtility</a></td><td class="bar" id="b0"><img src="../jacoco-resources/redbar.gif" width="26" height="10" title="92" alt="92"/><img src="../jacoco-resources/greenbar.gif" width="77" height="10" title="268" alt="268"/></td><td class="ctr2" id="c2">74%</td><td class="bar" id="d0"><img src="../jacoco-resources/redbar.gif" width="33" height="10" title="11" alt="11"/><img src="../jacoco-resources/greenbar.gif" width="87" height="10" title="29" alt="29"/></td><td class="ctr2" id="e2">72%</td><td class="ctr1" id="f0">10</td><td class="c tr2" id="g0">24</td><td class="ctr1" id="h0">15</td><td class="ctr2" id="i0">85</td><td class="ctr1" id="j1">0</td><td class="ctr2" id="k0">4</td><td class="ctr1" id="l1">0</td><td class="ctr2" id="m0">1</td></tr><tr><td id="a2"><a href="ParseException.html" class="el_class">ParseException</a></td><td class="bar" id="b1"><img src="../jacoco-resources/redbar.gif" width="1" height="10" title="4" alt="4"/></td><td class="ctr2" id="c3">0%</td><td class="bar" id="d3"/><td class="ctr2" id="e3">n/a</td><td class="ctr1" id="f1">1</td><td class="ctr2" id="g3">1</td><td class="ctr1" id="h1">2</td><td class="ctr2" id="i3">2</td><td class="ctr1" id="j0">1</td><td class="ctr2" id="k3">1</td><td class="ctr1" id="l0">1</td><td class="ctr2" id="m1">1</td></tr><tr><td id="a0"><a href="Base64Decoder.html" class="el_class">Base64Decoder</a></td><td class="bar" id="b2"><img src="../jacoco-resources/greenbar.gif" width="120" height="10" title="416" alt="416"/></td><td class="ctr2" id="c0">100%</td><td c lass="bar" id="d1"><img src="../jacoco-resources/redbar.gif" width="3" height="10" title="1" alt="1"/><img src="../jacoco-resources/greenbar.gif" width="63" height="10" title="21" alt="21"/></td><td class="ctr2" id="e1">95%</td><td class="ctr1" id="f2">1</td><td class="ctr2" id="g1">13</td><td class="ctr1" id="h2">0</td><td class="ctr2" id="i1">37</td><td class="ctr1" id="j2">0</td><td class="ctr2" id="k1">2</td><td class="ctr1" id="l2">0</td><td class="ctr2" id="m2">1</td></tr><tr><td id="a3"><a href="QuotedPrintableDecoder.html" class="el_class">QuotedPrintableDecoder</a></td><td class="bar" id="b3"><img src="../jacoco-resources/greenbar.gif" width="30" height="10" title="104" alt="104"/></td><td class="ctr2" id="c1">100%</td><td class="bar" id="d2"><img src="../jacoco-resources/greenbar.gif" width="42" height="10" title="14" alt="14"/></td><td class="ctr2" id="e0">100%</td><td class="ctr1" id="f3">0</td><td class="ctr2" id="g2">9</td><td class="ctr1" id="h3">0</td><td class="ctr2 " id="i2">29</td><td class="ctr1" id="j3">0</td><td class="ctr2" id="k2">2</td><td class="ctr1" id="l3">0</td><td class="ctr2" id="m3">1</td></tr></tbody></table><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.8.202204050719</span></div></body></html> \ No newline at end of file Added: websites/production/commons/content/proper/commons-fileupload/jacoco/org.apache.commons.fileupload.util.mime/index.source.html ============================================================================== --- websites/production/commons/content/proper/commons-fileupload/jacoco/org.apache.commons.fileupload.util.mime/index.source.html (added) +++ websites/production/commons/content/proper/commons-fileupload/jacoco/org.apache.commons.fileupload.util.mime/index.source.html Mon Feb 13 10:43:35 2023 @@ -0,0 +1 @@ +<?xml version="1.0" encoding="iso-8859-1"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>org.apache.commons.fileupload.util.mime</title><script type="text/javascript" src="../jacoco-resources/sort.js"></script></head><body onload="initialSort(['breadcrumb', 'coveragetable'])"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="index.html" class="el_class">Classes</a><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">Apache Commons FileUpload</a> > <span class="el_package">org.apache.commons.fileupload.util.mime</span></div><h1>org.apache.commons.fileupl oad.util.mime</h1><table class="coverage" cellspacing="0" id="coveragetable"><thead><tr><td class="sortable" id="a" onclick="toggleSort(this)">Element</td><td class="down sortable bar" id="b" onclick="toggleSort(this)">Missed Instructions</td><td class="sortable ctr2" id="c" onclick="toggleSort(this)">Cov.</td><td class="sortable bar" id="d" onclick="toggleSort(this)">Missed Branches</td><td class="sortable ctr2" id="e" onclick="toggleSort(this)">Cov.</td><td class="sortable ctr1" id="f" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="g" onclick="toggleSort(this)">Cxty</td><td class="sortable ctr1" id="h" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="i" onclick="toggleSort(this)">Lines</td><td class="sortable ctr1" id="j" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="k" onclick="toggleSort(this)">Methods</td><td class="sortable ctr1" id="l" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="m" onclick=" toggleSort(this)">Classes</td></tr></thead><tfoot><tr><td>Total</td><td class="bar">96 of 884</td><td class="ctr2">89%</td><td class="bar">12 of 76</td><td class="ctr2">84%</td><td class="ctr1">12</td><td class="ctr2">47</td><td class="ctr1">17</td><td class="ctr2">153</td><td class="ctr1">1</td><td class="ctr2">9</td><td class="ctr1">1</td><td class="ctr2">4</td></tr></tfoot><tbody><tr><td id="a1"><a href="MimeUtility.java.html" class="el_source">MimeUtility.java</a></td><td class="bar" id="b0"><img src="../jacoco-resources/redbar.gif" width="26" height="10" title="92" alt="92"/><img src="../jacoco-resources/greenbar.gif" width="77" height="10" title="268" alt="268"/></td><td class="ctr2" id="c2">74%</td><td class="bar" id="d0"><img src="../jacoco-resources/redbar.gif" width="33" height="10" title="11" alt="11"/><img src="../jacoco-resources/greenbar.gif" width="87" height="10" title="29" alt="29"/></td><td class="ctr2" id="e2">72%</td><td class="ctr1" id="f0">10</td><td class="ctr 2" id="g0">24</td><td class="ctr1" id="h0">15</td><td class="ctr2" id="i0">85</td><td class="ctr1" id="j1">0</td><td class="ctr2" id="k0">4</td><td class="ctr1" id="l1">0</td><td class="ctr2" id="m0">1</td></tr><tr><td id="a2"><a href="ParseException.java.html" class="el_source">ParseException.java</a></td><td class="bar" id="b1"><img src="../jacoco-resources/redbar.gif" width="1" height="10" title="4" alt="4"/></td><td class="ctr2" id="c3">0%</td><td class="bar" id="d3"/><td class="ctr2" id="e3">n/a</td><td class="ctr1" id="f1">1</td><td class="ctr2" id="g3">1</td><td class="ctr1" id="h1">2</td><td class="ctr2" id="i3">2</td><td class="ctr1" id="j0">1</td><td class="ctr2" id="k3">1</td><td class="ctr1" id="l0">1</td><td class="ctr2" id="m1">1</td></tr><tr><td id="a0"><a href="Base64Decoder.java.html" class="el_source">Base64Decoder.java</a></td><td class="bar" id="b2"><img src="../jacoco-resources/greenbar.gif" width="120" height="10" title="416" alt="416"/></td><td class="ctr2" id ="c0">100%</td><td class="bar" id="d1"><img src="../jacoco-resources/redbar.gif" width="3" height="10" title="1" alt="1"/><img src="../jacoco-resources/greenbar.gif" width="63" height="10" title="21" alt="21"/></td><td class="ctr2" id="e1">95%</td><td class="ctr1" id="f2">1</td><td class="ctr2" id="g1">13</td><td class="ctr1" id="h2">0</td><td class="ctr2" id="i1">37</td><td class="ctr1" id="j2">0</td><td class="ctr2" id="k1">2</td><td class="ctr1" id="l2">0</td><td class="ctr2" id="m2">1</td></tr><tr><td id="a3"><a href="QuotedPrintableDecoder.java.html" class="el_source">QuotedPrintableDecoder.java</a></td><td class="bar" id="b3"><img src="../jacoco-resources/greenbar.gif" width="30" height="10" title="104" alt="104"/></td><td class="ctr2" id="c1">100%</td><td class="bar" id="d2"><img src="../jacoco-resources/greenbar.gif" width="42" height="10" title="14" alt="14"/></td><td class="ctr2" id="e0">100%</td><td class="ctr1" id="f3">0</td><td class="ctr2" id="g2">9</td><td class="ctr1 " id="h3">0</td><td class="ctr2" id="i2">29</td><td class="ctr1" id="j3">0</td><td class="ctr2" id="k2">2</td><td class="ctr1" id="l3">0</td><td class="ctr2" id="m3">1</td></tr></tbody></table><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.8.202204050719</span></div></body></html> \ No newline at end of file Added: websites/production/commons/content/proper/commons-fileupload/jacoco/org.apache.commons.fileupload.util/FileItemHeadersImpl.html ============================================================================== --- websites/production/commons/content/proper/commons-fileupload/jacoco/org.apache.commons.fileupload.util/FileItemHeadersImpl.html (added) +++ websites/production/commons/content/proper/commons-fileupload/jacoco/org.apache.commons.fileupload.util/FileItemHeadersImpl.html Mon Feb 13 10:43:35 2023 @@ -0,0 +1 @@ +<?xml version="1.0" encoding="iso-8859-1"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>FileItemHeadersImpl</title><script type="text/javascript" src="../jacoco-resources/sort.js"></script></head><body onload="initialSort(['breadcrumb'])"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">Apache Commons FileUpload</a> > <a href="index.html" class="el_package">org.apache.commons.fileupload.util</a> > <span class="el_class">FileItemHeadersImpl</span></div><h1>FileItemHeadersImpl</h1><table class="coverage" ce llspacing="0" id="coveragetable"><thead><tr><td class="sortable" id="a" onclick="toggleSort(this)">Element</td><td class="down sortable bar" id="b" onclick="toggleSort(this)">Missed Instructions</td><td class="sortable ctr2" id="c" onclick="toggleSort(this)">Cov.</td><td class="sortable bar" id="d" onclick="toggleSort(this)">Missed Branches</td><td class="sortable ctr2" id="e" onclick="toggleSort(this)">Cov.</td><td class="sortable ctr1" id="f" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="g" onclick="toggleSort(this)">Cxty</td><td class="sortable ctr1" id="h" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="i" onclick="toggleSort(this)">Lines</td><td class="sortable ctr1" id="j" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="k" onclick="toggleSort(this)">Methods</td></tr></thead><tfoot><tr><td>Total</td><td class="bar">0 of 79</td><td class="ctr2">100%</td><td class="bar">0 of 6</td><td class="ctr2">100%</td><td class="c tr1">0</td><td class="ctr2">8</td><td class="ctr1">0</td><td class="ctr2">20</td><td class="ctr1">0</td><td class="ctr2">5</td></tr></tfoot><tbody><tr><td id="a0"><a href="FileItemHeadersImpl.java.html#L89" class="el_method">addHeader(String, String)</a></td><td class="bar" id="b0"><img src="../jacoco-resources/greenbar.gif" width="120" height="10" title="28" alt="28"/></td><td class="ctr2" id="c0">100%</td><td class="bar" id="d0"><img src="../jacoco-resources/greenbar.gif" width="120" height="10" title="2" alt="2"/></td><td class="ctr2" id="e0">100%</td><td class="ctr1" id="f0">0</td><td class="ctr2" id="g0">2</td><td class="ctr1" id="h0">0</td><td class="ctr2" id="i0">7</td><td class="ctr1" id="j0">0</td><td class="ctr2" id="k0">1</td></tr><tr><td id="a2"><a href="FileItemHeadersImpl.java.html#L53" class="el_method">getHeader(String)</a></td><td class="bar" id="b1"><img src="../jacoco-resources/greenbar.gif" width="85" height="10" title="20" alt="20"/></td><td class="ctr2" id="c1" >100%</td><td class="bar" id="d1"><img src="../jacoco-resources/greenbar.gif" >width="120" height="10" title="2" alt="2"/></td><td class="ctr2" >id="e1">100%</td><td class="ctr1" id="f1">0</td><td class="ctr2" >id="g1">2</td><td class="ctr1" id="h1">0</td><td class="ctr2" >id="i1">5</td><td class="ctr1" id="j1">0</td><td class="ctr2" >id="k1">1</td></tr><tr><td id="a4"><a >href="FileItemHeadersImpl.java.html#L74" >class="el_method">getHeaders(String)</a></td><td class="bar" id="b2"><img >src="../jacoco-resources/greenbar.gif" width="77" height="10" title="18" >alt="18"/></td><td class="ctr2" id="c2">100%</td><td class="bar" id="d2"><img >src="../jacoco-resources/greenbar.gif" width="120" height="10" title="2" >alt="2"/></td><td class="ctr2" id="e2">100%</td><td class="ctr1" >id="f2">0</td><td class="ctr2" id="g2">2</td><td class="ctr1" >id="h2">0</td><td class="ctr2" id="i2">5</td><td class="ctr1" >id="j2">0</td><td class="ctr2" id="k2">1</td></tr><tr><td id="a1"><a >href="FileItemHeadersImpl.java .html#L35" class="el_method">FileItemHeadersImpl()</a></td><td class="bar" id="b3"><img src="../jacoco-resources/greenbar.gif" width="34" height="10" title="8" alt="8"/></td><td class="ctr2" id="c3">100%</td><td class="bar" id="d3"/><td class="ctr2" id="e3">n/a</td><td class="ctr1" id="f3">0</td><td class="ctr2" id="g3">1</td><td class="ctr1" id="h3">0</td><td class="ctr2" id="i3">2</td><td class="ctr1" id="j3">0</td><td class="ctr2" id="k3">1</td></tr><tr><td id="a3"><a href="FileItemHeadersImpl.java.html#L66" class="el_method">getHeaderNames()</a></td><td class="bar" id="b4"><img src="../jacoco-resources/greenbar.gif" width="21" height="10" title="5" alt="5"/></td><td class="ctr2" id="c4">100%</td><td class="bar" id="d4"/><td class="ctr2" id="e4">n/a</td><td class="ctr1" id="f4">0</td><td class="ctr2" id="g4">1</td><td class="ctr1" id="h4">0</td><td class="ctr2" id="i4">1</td><td class="ctr1" id="j4">0</td><td class="ctr2" id="k4">1</td></tr></tbody></table><div class="footer"><sp an class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.8.202204050719</span></div></body></html> \ No newline at end of file Added: websites/production/commons/content/proper/commons-fileupload/jacoco/org.apache.commons.fileupload.util/FileItemHeadersImpl.java.html ============================================================================== --- websites/production/commons/content/proper/commons-fileupload/jacoco/org.apache.commons.fileupload.util/FileItemHeadersImpl.java.html (added) +++ websites/production/commons/content/proper/commons-fileupload/jacoco/org.apache.commons.fileupload.util/FileItemHeadersImpl.java.html Mon Feb 13 10:43:35 2023 @@ -0,0 +1,99 @@ +<?xml version="1.0" encoding="iso-8859-1"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>FileItemHeadersImpl.java</title><link rel="stylesheet" href="../jacoco-resources/prettify.css" type="text/css"/><script type="text/javascript" src="../jacoco-resources/prettify.js"></script></head><body onload="window['PR_TAB_WIDTH']=4;prettyPrint()"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">Apache Commons FileUpload</a> > <a href="index.source.html" class="el_package">org.apache.commons.fileupload.util</a> > <s pan class="el_source">FileItemHeadersImpl.java</span></div><h1>FileItemHeadersImpl.java</h1><pre class="source lang-java linenums">/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.commons.fileupload.util; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Locale; +import java.util.Map; + +import org.apache.commons.fileupload.FileItemHeaders; + +/** + * Default implementation of the {@link FileItemHeaders} interface. + * + * @since 1.2.1 + */ +<span class="fc" id="L35">public class FileItemHeadersImpl implements FileItemHeaders, Serializable {</span> + + /** + * Serial version UID, being used, if serialized. + */ + private static final long serialVersionUID = -4455695752627032559L; + + /** + * Map of <code>String</code> keys to a <code>List</code> of + * <code>String</code> instances. + */ +<span class="fc" id="L46"> private final Map<String, List<String>> headerNameToValueListMap = new LinkedHashMap<String, List<String>>();</span> + + /** + * {@inheritDoc} + */ + @Override + public String getHeader(String name) { +<span class="fc" id="L53"> String nameLower = name.toLowerCase(Locale.ENGLISH);</span> +<span class="fc" id="L54"> List<String> headerValueList = headerNameToValueListMap.get(nameLower);</span> +<span class="fc bfc" id="L55" title="All 2 branches covered."> if (null == headerValueList) {</span> +<span class="fc" id="L56"> return null;</span> + } +<span class="fc" id="L58"> return headerValueList.get(0);</span> + } + + /** + * {@inheritDoc} + */ + @Override + public Iterator<String> getHeaderNames() { +<span class="fc" id="L66"> return headerNameToValueListMap.keySet().iterator();</span> + } + + /** + * {@inheritDoc} + */ + @Override + public Iterator<String> getHeaders(String name) { +<span class="fc" id="L74"> String nameLower = name.toLowerCase(Locale.ENGLISH);</span> +<span class="fc" id="L75"> List<String> headerValueList = headerNameToValueListMap.get(nameLower);</span> +<span class="fc bfc" id="L76" title="All 2 branches covered."> if (null == headerValueList) {</span> +<span class="fc" id="L77"> headerValueList = Collections.emptyList();</span> + } +<span class="fc" id="L79"> return headerValueList.iterator();</span> + } + + /** + * Method to add header values to this instance. + * + * @param name name of this header + * @param value value of this header + */ + public synchronized void addHeader(String name, String value) { +<span class="fc" id="L89"> String nameLower = name.toLowerCase(Locale.ENGLISH);</span> +<span class="fc" id="L90"> List<String> headerValueList = headerNameToValueListMap.get(nameLower);</span> +<span class="fc bfc" id="L91" title="All 2 branches covered."> if (null == headerValueList) {</span> +<span class="fc" id="L92"> headerValueList = new ArrayList<String>();</span> +<span class="fc" id="L93"> headerNameToValueListMap.put(nameLower, headerValueList);</span> + } +<span class="fc" id="L95"> headerValueList.add(value);</span> +<span class="fc" id="L96"> }</span> + +} +</pre><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.8.202204050719</span></div></body></html> \ No newline at end of file Added: websites/production/commons/content/proper/commons-fileupload/jacoco/org.apache.commons.fileupload.util/LimitedInputStream.html ============================================================================== --- websites/production/commons/content/proper/commons-fileupload/jacoco/org.apache.commons.fileupload.util/LimitedInputStream.html (added) +++ websites/production/commons/content/proper/commons-fileupload/jacoco/org.apache.commons.fileupload.util/LimitedInputStream.html Mon Feb 13 10:43:35 2023 @@ -0,0 +1 @@ +<?xml version="1.0" encoding="iso-8859-1"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>LimitedInputStream</title><script type="text/javascript" src="../jacoco-resources/sort.js"></script></head><body onload="initialSort(['breadcrumb'])"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">Apache Commons FileUpload</a> > <a href="index.html" class="el_package">org.apache.commons.fileupload.util</a> > <span class="el_class">LimitedInputStream</span></div><h1>LimitedInputStream</h1><table class="coverage" cells pacing="0" id="coveragetable"><thead><tr><td class="sortable" id="a" onclick="toggleSort(this)">Element</td><td class="down sortable bar" id="b" onclick="toggleSort(this)">Missed Instructions</td><td class="sortable ctr2" id="c" onclick="toggleSort(this)">Cov.</td><td class="sortable bar" id="d" onclick="toggleSort(this)">Missed Branches</td><td class="sortable ctr2" id="e" onclick="toggleSort(this)">Cov.</td><td class="sortable ctr1" id="f" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="g" onclick="toggleSort(this)">Cxty</td><td class="sortable ctr1" id="h" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="i" onclick="toggleSort(this)">Lines</td><td class="sortable ctr1" id="j" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="k" onclick="toggleSort(this)">Methods</td></tr></thead><tfoot><tr><td>Total</td><td class="bar">22 of 64</td><td class="ctr2">65%</td><td class="bar">2 of 6</td><td class="ctr2">66%</td><td class="ctr1" >2</td><td class="ctr2">9</td><td class="ctr1">6</td><td >class="ctr2">20</td><td class="ctr1">1</td><td >class="ctr2">6</td></tr></tfoot><tbody><tr><td id="a4"><a >href="LimitedInputStream.java.html#L99" class="el_method">read()</a></td><td >class="bar" id="b0"><img src="../jacoco-resources/redbar.gif" width="101" >height="10" title="16" alt="16"/></td><td class="ctr2" id="c5">0%</td><td >class="bar" id="d0"><img src="../jacoco-resources/redbar.gif" width="120" >height="10" title="2" alt="2"/></td><td class="ctr2" id="e2">0%</td><td >class="ctr1" id="f0">2</td><td class="ctr2" id="g0">2</td><td class="ctr1" >id="h0">5</td><td class="ctr2" id="i0">5</td><td class="ctr1" >id="j0">1</td><td class="ctr2" id="k0">1</td></tr><tr><td id="a0"><a >href="LimitedInputStream.java.html#L75" >class="el_method">checkLimit()</a></td><td class="bar" id="b1"><img >src="../jacoco-resources/redbar.gif" width="37" height="10" title="6" >alt="6"/><img src="../jacoco-resources/greenbar.gif" width="44" height="10" >titl e="7" alt="7"/></td><td class="ctr2" id="c4">53%</td><td class="bar" id="d1"><img src="../jacoco-resources/greenbar.gif" width="120" height="10" title="2" alt="2"/></td><td class="ctr2" id="e0">100%</td><td class="ctr1" id="f1">0</td><td class="ctr2" id="g1">2</td><td class="ctr1" id="h1">1</td><td class="ctr2" id="i2">3</td><td class="ctr1" id="j1">0</td><td class="ctr2" id="k1">1</td></tr><tr><td id="a5"><a href="LimitedInputStream.java.html#L132" class="el_method">read(byte[], int, int)</a></td><td class="bar" id="b2"><img src="../jacoco-resources/greenbar.gif" width="120" height="10" title="19" alt="19"/></td><td class="ctr2" id="c0">100%</td><td class="bar" id="d2"><img src="../jacoco-resources/greenbar.gif" width="120" height="10" title="2" alt="2"/></td><td class="ctr2" id="e1">100%</td><td class="ctr1" id="f2">0</td><td class="ctr2" id="g2">2</td><td class="ctr1" id="h2">0</td><td class="ctr2" id="i1">5</td><td class="ctr1" id="j2">0</td><td class="ctr2" id="k2">1</td></tr>< tr><td id="a3"><a href="LimitedInputStream.java.html#L52" class="el_method">LimitedInputStream(InputStream, long)</a></td><td class="bar" id="b3"><img src="../jacoco-resources/greenbar.gif" width="44" height="10" title="7" alt="7"/></td><td class="ctr2" id="c1">100%</td><td class="bar" id="d3"/><td class="ctr2" id="e3">n/a</td><td class="ctr1" id="f3">0</td><td class="ctr2" id="g3">1</td><td class="ctr1" id="h3">0</td><td class="ctr2" id="i3">3</td><td class="ctr1" id="j3">0</td><td class="ctr2" id="k3">1</td></tr><tr><td id="a1"><a href="LimitedInputStream.java.html#L162" class="el_method">close()</a></td><td class="bar" id="b4"><img src="../jacoco-resources/greenbar.gif" width="37" height="10" title="6" alt="6"/></td><td class="ctr2" id="c2">100%</td><td class="bar" id="d4"/><td class="ctr2" id="e4">n/a</td><td class="ctr1" id="f4">0</td><td class="ctr2" id="g4">1</td><td class="ctr1" id="h4">0</td><td class="ctr2" id="i4">3</td><td class="ctr1" id="j4">0</td><td class="ctr2" id=" k4">1</td></tr><tr><td id="a2"><a href="LimitedInputStream.java.html#L148" class="el_method">isClosed()</a></td><td class="bar" id="b5"><img src="../jacoco-resources/greenbar.gif" width="18" height="10" title="3" alt="3"/></td><td class="ctr2" id="c3">100%</td><td class="bar" id="d5"/><td class="ctr2" id="e5">n/a</td><td class="ctr1" id="f5">0</td><td class="ctr2" id="g5">1</td><td class="ctr1" id="h5">0</td><td class="ctr2" id="i5">1</td><td class="ctr1" id="j5">0</td><td class="ctr2" id="k5">1</td></tr></tbody></table><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.8.202204050719</span></div></body></html> \ No newline at end of file Added: websites/production/commons/content/proper/commons-fileupload/jacoco/org.apache.commons.fileupload.util/LimitedInputStream.java.html ============================================================================== --- websites/production/commons/content/proper/commons-fileupload/jacoco/org.apache.commons.fileupload.util/LimitedInputStream.java.html (added) +++ websites/production/commons/content/proper/commons-fileupload/jacoco/org.apache.commons.fileupload.util/LimitedInputStream.java.html Mon Feb 13 10:43:35 2023 @@ -0,0 +1,167 @@ +<?xml version="1.0" encoding="iso-8859-1"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>LimitedInputStream.java</title><link rel="stylesheet" href="../jacoco-resources/prettify.css" type="text/css"/><script type="text/javascript" src="../jacoco-resources/prettify.js"></script></head><body onload="window['PR_TAB_WIDTH']=4;prettyPrint()"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">Apache Commons FileUpload</a> > <a href="index.source.html" class="el_package">org.apache.commons.fileupload.util</a> > <sp an class="el_source">LimitedInputStream.java</span></div><h1>LimitedInputStream.java</h1><pre class="source lang-java linenums">/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.commons.fileupload.util; + +import java.io.FilterInputStream; +import java.io.IOException; +import java.io.InputStream; + +/** + * An input stream, which limits its data size. This stream is + * used, if the content length is unknown. + */ +public abstract class LimitedInputStream extends FilterInputStream implements Closeable { + + /** + * The maximum size of an item, in bytes. + */ + private final long sizeMax; + + /** + * The current number of bytes. + */ + private long count; + + /** + * Whether this stream is already closed. + */ + private boolean closed; + + /** + * Creates a new instance. + * + * @param inputStream The input stream, which shall be limited. + * @param pSizeMax The limit; no more than this number of bytes + * shall be returned by the source stream. + */ + public LimitedInputStream(InputStream inputStream, long pSizeMax) { +<span class="fc" id="L52"> super(inputStream);</span> +<span class="fc" id="L53"> sizeMax = pSizeMax;</span> +<span class="fc" id="L54"> }</span> + + /** + * Called to indicate, that the input streams limit has + * been exceeded. + * + * @param pSizeMax The input streams limit, in bytes. + * @param pCount The actual number of bytes. + * @throws IOException The called method is expected + * to raise an IOException. + */ + protected abstract void raiseError(long pSizeMax, long pCount) + throws IOException; + + /** + * Called to check, whether the input streams + * limit is reached. + * + * @throws IOException The given limit is exceeded. + */ + private void checkLimit() throws IOException { +<span class="fc bfc" id="L75" title="All 2 branches covered."> if (count > sizeMax) {</span> +<span class="nc" id="L76"> raiseError(sizeMax, count);</span> + } +<span class="fc" id="L78"> }</span> + + /** + * Reads the next byte of data from this input stream. The value + * byte is returned as an <code>int</code> in the range + * <code>0</code> to <code>255</code>. If no byte is available + * because the end of the stream has been reached, the value + * <code>-1</code> is returned. This method blocks until input data + * is available, the end of the stream is detected, or an exception + * is thrown. + * <p> + * This method + * simply performs <code>in.read()</code> and returns the result. + * + * @return the next byte of data, or <code>-1</code> if the end of the + * stream is reached. + * @throws IOException if an I/O error occurs. + * @see java.io.FilterInputStream#in + */ + @Override + public int read() throws IOException { +<span class="nc" id="L99"> int res = super.read();</span> +<span class="nc bnc" id="L100" title="All 2 branches missed."> if (res != -1) {</span> +<span class="nc" id="L101"> count++;</span> +<span class="nc" id="L102"> checkLimit();</span> + } +<span class="nc" id="L104"> return res;</span> + } + + /** + * Reads up to <code>len</code> bytes of data from this input stream + * into an array of bytes. If <code>len</code> is not zero, the method + * blocks until some input is available; otherwise, no + * bytes are read and <code>0</code> is returned. + * <p> + * This method simply performs <code>in.read(b, off, len)</code> + * and returns the result. + * + * @param b the buffer into which the data is read. + * @param off The start offset in the destination array + * <code>b</code>. + * @param len the maximum number of bytes read. + * @return the total number of bytes read into the buffer, or + * <code>-1</code> if there is no more data because the end of + * the stream has been reached. + * @throws NullPointerException If <code>b</code> is <code>null</code>. + * @throws IndexOutOfBoundsException If <code>off</code> is negative, + * <code>len</code> is negative, or <code>len</code> is greater than + * <code>b.length - off</code> + * @throws IOException if an I/O error occurs. + * @see java.io.FilterInputStream#in + */ + @Override + public int read(byte[] b, int off, int len) throws IOException { +<span class="fc" id="L132"> int res = super.read(b, off, len);</span> +<span class="fc bfc" id="L133" title="All 2 branches covered."> if (res > 0) {</span> +<span class="fc" id="L134"> count += res;</span> +<span class="fc" id="L135"> checkLimit();</span> + } +<span class="fc" id="L137"> return res;</span> + } + + /** + * Returns, whether this stream is already closed. + * + * @return True, if the stream is closed, otherwise false. + * @throws IOException An I/O error occurred. + */ + @Override + public boolean isClosed() throws IOException { +<span class="fc" id="L148"> return closed;</span> + } + + /** + * Closes this input stream and releases any system resources + * associated with the stream. + * This + * method simply performs <code>in.close()</code>. + * + * @throws IOException if an I/O error occurs. + * @see java.io.FilterInputStream#in + */ + @Override + public void close() throws IOException { +<span class="fc" id="L162"> closed = true;</span> +<span class="fc" id="L163"> super.close();</span> +<span class="fc" id="L164"> }</span> + +} +</pre><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.8.202204050719</span></div></body></html> \ No newline at end of file Added: websites/production/commons/content/proper/commons-fileupload/jacoco/org.apache.commons.fileupload.util/Streams.html ============================================================================== --- websites/production/commons/content/proper/commons-fileupload/jacoco/org.apache.commons.fileupload.util/Streams.html (added) +++ websites/production/commons/content/proper/commons-fileupload/jacoco/org.apache.commons.fileupload.util/Streams.html Mon Feb 13 10:43:35 2023 @@ -0,0 +1 @@ +<?xml version="1.0" encoding="iso-8859-1"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>Streams</title><script type="text/javascript" src="../jacoco-resources/sort.js"></script></head><body onload="initialSort(['breadcrumb'])"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">Apache Commons FileUpload</a> > <a href="index.html" class="el_package">org.apache.commons.fileupload.util</a> > <span class="el_class">Streams</span></div><h1>Streams</h1><table class="coverage" cellspacing="0" id="coveragetable"><th ead><tr><td class="sortable" id="a" onclick="toggleSort(this)">Element</td><td class="down sortable bar" id="b" onclick="toggleSort(this)">Missed Instructions</td><td class="sortable ctr2" id="c" onclick="toggleSort(this)">Cov.</td><td class="sortable bar" id="d" onclick="toggleSort(this)">Missed Branches</td><td class="sortable ctr2" id="e" onclick="toggleSort(this)">Cov.</td><td class="sortable ctr1" id="f" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="g" onclick="toggleSort(this)">Cxty</td><td class="sortable ctr1" id="h" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="i" onclick="toggleSort(this)">Lines</td><td class="sortable ctr1" id="j" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="k" onclick="toggleSort(this)">Methods</td></tr></thead><tfoot><tr><td>Total</td><td class="bar">27 of 135</td><td class="ctr2">80%</td><td class="bar">2 of 20</td><td class="ctr2">90%</td><td class="ctr1">4</td><td class="ctr2">15</td> <td class="ctr1">7</td><td class="ctr2">39</td><td class="ctr1">2</td><td class="ctr2">5</td></tr></tfoot><tbody><tr><td id="a1"><a href="Streams.java.html#L157" class="el_method">asString(InputStream, String)</a></td><td class="bar" id="b0"><img src="../jacoco-resources/redbar.gif" width="28" height="10" title="13" alt="13"/></td><td class="ctr2" id="c3">0%</td><td class="bar" id="d2"/><td class="ctr2" id="e2">n/a</td><td class="ctr1" id="f1">1</td><td class="ctr2" id="g2">1</td><td class="ctr1" id="h0">3</td><td class="ctr2" id="i2">3</td><td class="ctr1" id="j0">1</td><td class="ctr2" id="k0">1</td></tr><tr><td id="a0"><a href="Streams.java.html#L140" class="el_method">asString(InputStream)</a></td><td class="bar" id="b1"><img src="../jacoco-resources/redbar.gif" width="26" height="10" title="12" alt="12"/></td><td class="ctr2" id="c4">0%</td><td class="bar" id="d3"/><td class="ctr2" id="e3">n/a</td><td class="ctr1" id="f2">1</td><td class="ctr2" id="g3">1</td><td class="ctr1" id ="h1">3</td><td class="ctr2" id="i3">3</td><td class="ctr1" id="j1">1</td><td class="ctr2" id="k1">1</td></tr><tr><td id="a4"><a href="Streams.java.html#L93" class="el_method">copy(InputStream, OutputStream, boolean, byte[])</a></td><td class="bar" id="b2"><img src="../jacoco-resources/redbar.gif" width="4" height="10" title="2" alt="2"/><img src="../jacoco-resources/greenbar.gif" width="115" height="10" title="52" alt="52"/></td><td class="ctr2" id="c2">96%</td><td class="bar" id="d0"><img src="../jacoco-resources/redbar.gif" width="20" height="10" title="2" alt="2"/><img src="../jacoco-resources/greenbar.gif" width="100" height="10" title="10" alt="10"/></td><td class="ctr2" id="e1">83%</td><td class="ctr1" id="f0">2</td><td class="ctr2" id="g0">7</td><td class="ctr1" id="h2">1</td><td class="ctr2" id="i0">22</td><td class="ctr1" id="j2">0</td><td class="ctr2" id="k2">1</td></tr><tr><td id="a2"><a href="Streams.java.html#L173" class="el_method">checkFileName(String)</a></td><td cl ass="bar" id="b3"><img src="../jacoco-resources/greenbar.gif" width="108" height="10" title="49" alt="49"/></td><td class="ctr2" id="c0">100%</td><td class="bar" id="d1"><img src="../jacoco-resources/greenbar.gif" width="80" height="10" title="8" alt="8"/></td><td class="ctr2" id="e0">100%</td><td class="ctr1" id="f3">0</td><td class="ctr2" id="g1">5</td><td class="ctr1" id="h3">0</td><td class="ctr2" id="i1">10</td><td class="ctr1" id="j3">0</td><td class="ctr2" id="k3">1</td></tr><tr><td id="a3"><a href="Streams.java.html#L68" class="el_method">copy(InputStream, OutputStream, boolean)</a></td><td class="bar" id="b4"><img src="../jacoco-resources/greenbar.gif" width="15" height="10" title="7" alt="7"/></td><td class="ctr2" id="c1">100%</td><td class="bar" id="d4"/><td class="ctr2" id="e4">n/a</td><td class="ctr1" id="f4">0</td><td class="ctr2" id="g4">1</td><td class="ctr1" id="h4">0</td><td class="ctr2" id="i4">1</td><td class="ctr1" id="j4">0</td><td class="ctr2" id="k4">1</td></ tr></tbody></table><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.8.202204050719</span></div></body></html> \ No newline at end of file Added: websites/production/commons/content/proper/commons-fileupload/jacoco/org.apache.commons.fileupload.util/Streams.java.html ============================================================================== --- websites/production/commons/content/proper/commons-fileupload/jacoco/org.apache.commons.fileupload.util/Streams.java.html (added) +++ websites/production/commons/content/proper/commons-fileupload/jacoco/org.apache.commons.fileupload.util/Streams.java.html Mon Feb 13 10:43:35 2023 @@ -0,0 +1,194 @@ +<?xml version="1.0" encoding="iso-8859-1"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>Streams.java</title><link rel="stylesheet" href="../jacoco-resources/prettify.css" type="text/css"/><script type="text/javascript" src="../jacoco-resources/prettify.js"></script></head><body onload="window['PR_TAB_WIDTH']=4;prettyPrint()"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">Apache Commons FileUpload</a> > <a href="index.source.html" class="el_package">org.apache.commons.fileupload.util</a> > <span class="e l_source">Streams.java</span></div><h1>Streams.java</h1><pre class="source lang-java linenums">/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.commons.fileupload.util; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; + +import org.apache.commons.fileupload.InvalidFileNameException; +import org.apache.commons.io.IOUtils; + +/** + * Utility class for working with streams. + */ +public final class Streams { + + /** + * Private constructor, to prevent instantiation. + * This class has only static methods. + */ + private Streams() { + // Does nothing + } + + /** + * Default buffer size for use in + * {@link #copy(InputStream, OutputStream, boolean)}. + */ + public static final int DEFAULT_BUFFER_SIZE = 8192; + + /** + * Copies the contents of the given {@link InputStream} + * to the given {@link OutputStream}. Shortcut for + * <pre> + * copy(pInputStream, pOutputStream, new byte[8192]); + * </pre> + * + * @param inputStream The input stream, which is being read. + * It is guaranteed, that {@link InputStream#close()} is called + * on the stream. + * @param outputStream The output stream, to which data should + * be written. May be null, in which case the input streams + * contents are simply discarded. + * @param closeOutputStream True guarantees, that {@link OutputStream#close()} + * is called on the stream. False indicates, that only + * {@link OutputStream#flush()} should be called finally. + * + * @return Number of bytes, which have been copied. + * @throws IOException An I/O error occurred. + */ + public static long copy(InputStream inputStream, OutputStream outputStream, boolean closeOutputStream) + throws IOException { +<span class="fc" id="L68"> return copy(inputStream, outputStream, closeOutputStream, new byte[DEFAULT_BUFFER_SIZE]);</span> + } + + /** + * Copies the contents of the given {@link InputStream} + * to the given {@link OutputStream}. + * + * @param inputStream The input stream, which is being read. + * It is guaranteed, that {@link InputStream#close()} is called + * on the stream. + * @param outputStream The output stream, to which data should + * be written. May be null, in which case the input streams + * contents are simply discarded. + * @param closeOutputStream True guarantees, that {@link OutputStream#close()} + * is called on the stream. False indicates, that only + * {@link OutputStream#flush()} should be called finally. + * @param buffer Temporary buffer, which is to be used for + * copying data. + * @return Number of bytes, which have been copied. + * @throws IOException An I/O error occurred. + */ + public static long copy(InputStream inputStream, + OutputStream outputStream, boolean closeOutputStream, + byte[] buffer) + throws IOException { +<span class="fc" id="L93"> OutputStream out = outputStream;</span> +<span class="fc" id="L94"> InputStream in = inputStream;</span> + try { +<span class="fc" id="L96"> long total = 0;</span> + for (;;) { +<span class="fc" id="L98"> int res = in.read(buffer);</span> +<span class="fc bfc" id="L99" title="All 2 branches covered."> if (res == -1) {</span> +<span class="fc" id="L100"> break;</span> + } +<span class="pc bpc" id="L102" title="1 of 2 branches missed."> if (res > 0) {</span> +<span class="fc" id="L103"> total += res;</span> +<span class="fc bfc" id="L104" title="All 2 branches covered."> if (out != null) {</span> +<span class="fc" id="L105"> out.write(buffer, 0, res);</span> + } + } +<span class="fc" id="L108"> }</span> +<span class="fc bfc" id="L109" title="All 2 branches covered."> if (out != null) {</span> +<span class="pc bpc" id="L110" title="1 of 2 branches missed."> if (closeOutputStream) {</span> +<span class="fc" id="L111"> out.close();</span> + } else { +<span class="nc" id="L113"> out.flush();</span> + } +<span class="fc" id="L115"> out = null;</span> + } +<span class="fc" id="L117"> in.close();</span> +<span class="fc" id="L118"> in = null;</span> +<span class="fc" id="L119"> return total;</span> + } finally { +<span class="fc" id="L121"> IOUtils.closeQuietly(in);</span> +<span class="fc bfc" id="L122" title="All 2 branches covered."> if (closeOutputStream) {</span> +<span class="fc" id="L123"> IOUtils.closeQuietly(out);</span> + } + } + } + + /** + * This convenience method allows to read a + * {@link org.apache.commons.fileupload.FileItemStream}'s + * content into a string. The platform's default character encoding + * is used for converting bytes into characters. + * + * @param inputStream The input stream to read. + * @see #asString(InputStream, String) + * @return The streams contents, as a string. + * @throws IOException An I/O error occurred. + */ + public static String asString(InputStream inputStream) throws IOException { +<span class="nc" id="L140"> ByteArrayOutputStream baos = new ByteArrayOutputStream();</span> +<span class="nc" id="L141"> copy(inputStream, baos, true);</span> +<span class="nc" id="L142"> return baos.toString();</span> + } + + /** + * This convenience method allows to read a + * {@link org.apache.commons.fileupload.FileItemStream}'s + * content into a string, using the given character encoding. + * + * @param inputStream The input stream to read. + * @param encoding The character encoding, typically "UTF-8". + * @see #asString(InputStream) + * @return The streams contents, as a string. + * @throws IOException An I/O error occurred. + */ + public static String asString(InputStream inputStream, String encoding) throws IOException { +<span class="nc" id="L157"> ByteArrayOutputStream baos = new ByteArrayOutputStream();</span> +<span class="nc" id="L158"> copy(inputStream, baos, true);</span> +<span class="nc" id="L159"> return baos.toString(encoding);</span> + } + + /** + * Checks, whether the given file name is valid in the sense, + * that it doesn't contain any NUL characters. If the file name + * is valid, it will be returned without any modifications. Otherwise, + * an {@link InvalidFileNameException} is raised. + * + * @param fileName The file name to check + * @return Unmodified file name, if valid. + * @throws InvalidFileNameException The file name was found to be invalid. + */ + public static String checkFileName(String fileName) { +<span class="fc bfc" id="L173" title="All 4 branches covered."> if (fileName != null && fileName.indexOf('\u0000') != -1) {</span> + // pFileName.replace("\u0000", "\\0") +<span class="fc" id="L175"> final StringBuilder sb = new StringBuilder();</span> +<span class="fc bfc" id="L176" title="All 2 branches covered."> for (int i = 0; i < fileName.length(); i++) {</span> +<span class="fc" id="L177"> char c = fileName.charAt(i);</span> +<span class="fc bfc" id="L178" title="All 2 branches covered."> switch (c) {</span> + case 0: +<span class="fc" id="L180"> sb.append("\\0");</span> +<span class="fc" id="L181"> break;</span> + default: +<span class="fc" id="L183"> sb.append(c);</span> + break; + } + } +<span class="fc" id="L187"> throw new InvalidFileNameException(fileName,</span> + "Invalid file name: " + sb); + } +<span class="fc" id="L190"> return fileName;</span> + } + +} +</pre><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.8.202204050719</span></div></body></html> \ No newline at end of file
