Removes an attribute from the media tags

@param string $tag html tag which properties are extracted, for example "<video ...>....</video>"
@param string|array $attrname
@return string
963964
public static function remove_attributes($tag, $attrname) {
        if (is_array($attrname)) {
            $attrname = join('|', $attrname);
        }
        while (preg_match('/^(<[^>]*\b)(' . $attrname . ')=".*?"(.*)$/is', $tag, $matches)) {
            $tag = $matches[1] . $matches[3];
        }
        while (preg_match('~^(<[^>]*\b)(' . $attrname . ')([ />].*)$~is', $tag, $matches)) {
            // Some attributes may not have value, for example: <video controls>.
            $tag = $matches[1] . $matches[3];
        }
        return $tag;
    }
1298728
public function destroy(Tag $tag)
    {
        $tag->delete();

        return intend([
            'url' => route('adminarea.tags.index'),
            'with' => ['warning' => trans('cortex/foundation::messages.resource_deleted', ['resource' => trans('cortex/tags::common.tag'), 'identifier' => $tag->name])],
        ]);
    }
906503
public function strip(array $tag, $content) {
        $url = isset($tag['attributes']['href']) ? $tag['attributes']['href'] : $content;

        return parent::strip($tag, $url);
    }
1327875
public function remove($tag)
    {
        if ($this->count() == 0) {
            return [$this, null];
        }

        $deleted = null;

        foreach ($this->items as $key => $element) {
            if ($element === $tag) {
                $this->forget($key);

                $deleted = $tag;

                break;
            }
        }

        return [$this, $deleted];
    }
388107
protected function formatLabel($attrName)
    {
        if (strpos($attrName, '_') !== false) {
            $tempArr = explode('_', $attrName);
            foreach ($tempArr as $key => $item) {
                $tempArr[$key] = ucfirst(strtolower($item));
            }
            $attrName = implode(' ', $tempArr);
        } else {
            $capitals = [];
            for ($i = 0; $i < mb_strlen($attrName, 'UTF8'); ++$i) {
                if (StringHelper::isCapital($attrName[$i])) {
                    $capitals[] = $attrName[$i];
                }
            }

            foreach ($capitals as $capital) {
                $attrName = str_replace($capital, ' ' . $capital, $attrName);
            }

            $attrName = trim($attrName);
        }

        return $attrName;
    }
1066892
public function attribute( string $attr, string $value ): Tag
    {
        $this->attributes[$attr] = $value;

        return $this;
    }
514218
protected function writeTag($tagName, array $attributes, $content)
	{
		$xml = '<' . $tagName;
		foreach ($attributes as $attrName => $attrValue)
		{
			$xml .= ' ' . $attrName . '="' . htmlspecialchars($attrValue) . '"';
		}
		if ($content === '')
		{
			$xml .= '/>';
		}
		else
		{
			$xml .= '>' . $content . '</' . $tagName . '>';
		}

		return $xml;
	}
36824
private function getAttributes($tag)
    {
        if (!preg_match_all(self::ATTRIBUTE_REGEX, $tag, $matches)) {
            return [];
        }

        $attributes = [];
        for ($i = 0, $length = count($matches['name']); $i < $length; ++$i) {
            $value = $matches['value'][$i];

            if ('true' === $value || 'false' === $value) {
                $value = filter_var($value, FILTER_VALIDATE_BOOLEAN);
            }

            $attributes[$matches['name'][$i]] = $value;
        }

        return $attributes;
    }
770877
public function removeTag($tag)
    {
        $this->tag = $tag;
        $this->getLogger()->info('Removing tag: ' . $tag . ' from layout ID ' . $this->layoutId);
        $this->doPost('/layout/' . $this->layoutId . '/untag', [
            'tag' => [$tag]
        ]);

        return $this;
    }
749131
public static function add_attributes($tag, $attributes) {
        $tag = self::remove_attributes($tag, array_keys($attributes));
        if (!preg_match('/^(<.*?)(>.*)$/s', $tag, $matches)) {
            return $tag;
        }
        $rv = $matches[1];
        foreach ($attributes as $name => $value) {
            $rv .= " $name=\"".s($value).'"';
        }
        $rv .= $matches[2];
        return $rv;
    }
1219820
public Whitelist removeEnforcedAttribute(String tag, String attribute) {
        Validate.notEmpty(tag);
        Validate.notEmpty(attribute);

        TagName tagName = TagName.valueOf(tag);
        if(tagNames.contains(tagName) && enforcedAttributes.containsKey(tagName)) {
            AttributeKey attrKey = AttributeKey.valueOf(attribute);
            Map<AttributeKey, AttributeValue> attrMap = enforcedAttributes.get(tagName);
            attrMap.remove(attrKey);

            if(attrMap.isEmpty()) // Remove tag from enforced attribute map if no enforced attributes are present
                enforcedAttributes.remove(tagName);
        }
        return this;
    }
855748
public function removeSpecialCaseTag($tag)
    {
        if (($key = array_search($tag, $this->specialCaseTags)) !== false) {
            unset($this->specialCaseTags[$key]);

            $opening = $this->getOpeningTag($tag);
            $closing = $this->getClosingTag($tag);

            if (($key = array_search($opening, $this->specialCaseOpeningTags)) !== false) {
                unset($this->specialCaseOpeningTags[$key]);
            }
            if (($key = array_search($closing, $this->specialCaseClosingTags)) !== false) {
                unset($this->specialCaseClosingTags[$key]);
            }
        }

        return $this;
    }
693531
public function removeAttr($css, $attr = null)
    {
        if ($attr) {
            $attr = (array)preg_split('#[\s,]+#', $attr, -1, PREG_SPLIT_NO_EMPTY);
        }

        /**
         * @var \DOMElement $node
         */
        $query = $this->_document->getQuery();
        foreach ($this->_nodes as $node_0) {
            foreach ($query->css($css, $node_0) as $node) {
                foreach ($node->attributes as $attribute) {
                    if (!$attr || in_array($attribute->name, $attr, true)) {
                        $node->removeAttribute($attribute->name);
                    }
                }
            }
        }

        return $this;
    }
144238
protected function removeAttributionLink( $content ) {
		if ( stripos( $content, '<a' ) === false ) {
			// There are no <a> tags to look at, skip this
			return $content;
		}

		$changed = false;
		$html5 = new HtmlParser();
		$dom = $html5->loadHTML( $content );

		$urls = $dom->getElementsByTagName( 'a' );
		foreach ( $urls as $url ) {
			/** @var \DOMElement $url */
			// Is this the the attributionUrl?
			if ( $url->getAttribute( 'rel' ) === 'cc:attributionURL' ) {
				$url->parentNode->replaceChild(
					$dom->createTextNode( $url->nodeValue ),
					$url
				);
				$changed = true;
			}
		}

		if ( ! $changed ) {
			return $content;
		} else {
			$content = $html5->saveHTML( $dom );
			$content = $this->html5ToXhtml( $content );
			return $content;
		}
	}
972552
public static void removeAttribute(final AttributesImpl atts, final String qName) {
        final int i = atts.getIndex(qName);
        if (i != -1) {
            atts.removeAttribute(i);
        }
    }
1211762
public void removeSessionAttr(final String attrName) {
    final HttpSession sess = request.getSession(false);

    if (sess == null) {
      return;
    }

    sess.removeAttribute(attrName);
  }
799693
public static function attsToString(Tag &$Tag)
    {
        /*
         * Return empty string if tag does not have attributes.
         */
        if (empty($Tag->attributes)) {
            return '';
        }

        $r = ' ';
        foreach ($Tag->attributes as $key => $value) {
            /*
             * Validate the attribute name.
             */
            $tmp = $key;
            if (!$Tag->hasOption('dontValidateAttrs') && !self::ensureAttrNameValidation($key)) {
                self::debug(sprintf('Invalid attribute name "%s" was changed to "%s"', $tmp, $key), 2, 7);
            }

            /*
             * If we have an value we make sure critical letters are escaped and use the format :name=":value"
             */
            if (!empty($value)) {
                $tmp = $value;
                if (!$Tag->hasOption('dontValidateAttrs') && !self::ensureAttrValueValidation($value)) {
                    self::debug(sprintf('Dangerous attribute value "%s" was changed to "%s"', $tmp, $value), 2, 7);
                }
                $value = str_replace('"', '&quot;', $value);
                $r .= "$key=\"$value\" ";
            } elseif ($value !== false) {
                /*
                 * No value? Alright just take the name.
                 */
                $r .= $key.' ';
            }
        }

        /*
         * Remove the last space and return.
         */

        return rtrim($r, ' ');
    }