<NME> DOMDocument.php
<BEF> <?php

namespace Bramus\MCS;

/**
 * Represents an entire HTML or XML document; with some extras
 * @author Bramus! <bramus@bram.us>
 */
class DOMDocument extends \DOMDocument
{
    /**
     * Collection that indicate sources of element attribute values we want to check.
     *
     * @var array
     */
    public $tags = [
        'audio'  => ['src'],
        'embed'  => ['src'],
        'form'   => ['action'],
        'iframe' => ['src'],
        'img'    => ['src', 'srcset', 'data-src'],
        'link'   => ['href'],
        'object' => ['data'],
        'param'  => ['value'],
        'script' => ['src'],
        'source' => ['src', 'srcset'],
        'video'  => ['src']
    ];

    /**
     * Loop all links and extract their href value.
     *
     * @return array All href values.
     */
    public function extractLinks()
    {
        $links = [];

        /** @var \DOMElement $el */
        foreach ($this->getElementsByTagName('a') as $el) {
            if ($el->hasAttribute('href')) {
                $links[] = $el->getAttribute('href');
            }
        }

        return $links;
    }

    /**
     * Extract URLs which are found to be Mixed Content.
     *
     * @return array URLs
     */
    public function extractMixedContentUrls()
    {
        // Array holding all URLs which are found to be Mixed Content
        // We'll return this one at the very end
        $mixedContentUrls = [];

        // Loop through all the tags and attributes we want to find
        // references to mixed content
        foreach ($this->tags as $tag => $attributes) {
            /** @var \DOMElement $el */
            foreach ($this->getElementsByTagName($tag) as $el) {
                /** @var array $attributes */
                foreach ($attributes as $attribute) {
                    if ($el->hasAttribute($attribute)) {
                        $url = $el->getAttribute($attribute);
                        if (stripos($url, 'http://') !== false) {
                            $mixedContentUrls[] = $url;
                        }
                    }
                }
            }
        }

        // Return found URLs
        return $mixedContentUrls;
    }
}
                    $mixedContentUrls[] = $url;
                }
            }
        }

        // Check all `param` elements contained in the HTML
        foreach ($this->getElementsByTagName('param') as $el) {
            if ($el->hasAttribute('value') && $el->hasAttribute('name') && ($el->getAttribute('name') == 'movie')) {

<MSG> Check for src on source tag
<DFF> @@ -122,8 +122,15 @@ class DOMDocument extends \DOMDocument
                     $mixedContentUrls[] = $url;
                 }
             }
+            if ($el->hasAttribute('src')) {
+                $url = $el->getAttribute('src');
+                if (substr($url, 0, 7) == "http://") {
+                    $mixedContentUrls[] = $url;
+                }
+            }
         }
 
+
         // Check all `param` elements contained in the HTML
         foreach ($this->getElementsByTagName('param') as $el) {
             if ($el->hasAttribute('value') && $el->hasAttribute('name') && ($el->getAttribute('name') == 'movie')) {

{'addition_count': 7, 'commit_subject': 'Check for src on source tag', 'deletion_count': 0, 'file_extension': '.php', 'lang': 'php', 'license': 'mit', 'repo_name': 'bramus/mixed-content-scan'}