<commit_before><?php

namespace Extlib;

/**
 * Mailer class - change image for CID data.
 * 
 * @category    Extlib
 * @author      <NAME> <<EMAIL>>
 * @copyright   Copyright (c) 2012 <NAME> (mart)
 */
class Mail extends \Zend_Mail
{

    /**
     * Sets the HTML body for the message
     *
     * @param  string    $html
     * @param  string    $charset
     * @param  string    $encoding
     * @return \Zend_Mail 
     */
    public function setBodyHtml($html, $charset = null, $encoding = \Zend_Mime::ENCODING_QUOTEDPRINTABLE)
    {
        $this->setType(\Zend_Mime::MULTIPART_RELATED);

        $dom = new \DOMDocument(null, $this->getCharset());
        @$dom->loadHTML($html);

        $images = $dom->getElementsByTagName('img');
        for ($i = 0; $i < $images->length; $i++) {
            $img = $images->item($i);
            $url = $img->getAttribute('src');

            try {
                $client = new \Zend_Http_Client($url);
                $response = $client->request();

                if ($response->getStatus() === 200) {
                    $imageContent = $response->getBody();

                    $pathinfo = pathinfo($url);
                    $mimeType = $response->getHeader('Content-Type');

                    $cid = md5($pathinfo['filename']);
                    $html = str_replace($url, 'cid:' . $cid, $html);

                    $mime = new Zend_Mime_Part($imageContent);
                    $mime->id = $cid;
                    $mime->type = $mimeType;
                    $mime->disposition = Zend_Mime::DISPOSITION_INLINE;
                    $mime->encoding = Zend_Mime::ENCODING_BASE64;
                    $mime->filename = $pathinfo['basename'];

                    $this->addAttachment($mime);
                }
            } catch (\Exception $exc) {
                //Error on client connect - bad url?
            }
        }

        return parent::setBodyHtml($html, $charset, $encoding);
    }

}
<commit_msg>Update mail pckage<commit_after><?php

namespace Extlib;

/**
 * Mailer class - change image for CID data.
 * 
 * @category    Extlib
 * @author      <NAME> <<EMAIL>>
 * @copyright   Copyright (c) 2012 <NAME> (mart)
 */
class Mail extends \Zend_Mail
{

    /**
     * Sets the HTML body for the message
     *
     * @param  string    $html
     * @param  string    $charset
     * @param  string    $encoding
     * @return \Zend_Mail 
     */
    public function setBodyHtml($html, $charset = null, $encoding = \Zend_Mime::ENCODING_QUOTEDPRINTABLE)
    {
        $this->setType(\Zend_Mime::MULTIPART_RELATED);

        $dom = new \DOMDocument(null, $this->getCharset());
        @$dom->loadHTML($html);

        $images = $dom->getElementsByTagName('img');
        for ($i = 0; $i < $images->length; $i++) {
            $img = $images->item($i);
            $url = $img->getAttribute('src');

            try {
                $client = new \Zend_Http_Client($url);
                $response = $client->request();

                if ($response->getStatus() === 200) {
                    $imageContent = $response->getBody();

                    $pathinfo = pathinfo($url);
                    $mimeType = $response->getHeader('Content-Type');

                    $cid = md5($pathinfo['filename']);
                    $html = str_replace($url, 'cid:' . $cid, $html);

                    $mime = new \Zend_Mime_Part($imageContent);
                    $mime->id = $cid;
                    $mime->type = $mimeType;
                    $mime->disposition = \Zend_Mime::DISPOSITION_INLINE;
                    $mime->encoding = \Zend_Mime::ENCODING_BASE64;
                    $mime->filename = $pathinfo['basename'];

                    $this->addAttachment($mime);
                }
            } catch (\Exception $exc) {
                //Error on client connect - bad url?
            }
        }

        return parent::setBodyHtml($html, $charset, $encoding);
    }

}

{'fraction_non_alphanumeric': 0.14275220372184133, 'fraction_numerical': 0.0053868756121449556, 'mean_word_length': 1.5467581047381547, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 45, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4517961', 'n_tokens_mistral': 1288, 'n_tokens_neox': 1145, 'n_words': 236}