PHP 클래스 PicoFeed\Filter\Attribute

저자: Frederic Guillot
파일 보기 프로젝트 열기: fguillot/picofeed 1 사용 예제들

공개 메소드들

메소드 설명
__construct ( PicoFeed\Client\Url $website ) Constructor.
addAttributes ( string $tag, array $attributes ) : array Automatically add/override some attributes for specific tags.
filter ( string $tag, array $attributes ) : array Apply filters to the attributes list.
filterAllowedAttribute ( string $tag, string $attribute, string $value ) : boolean Return true if the value is allowed (remove not allowed attributes).
filterBlacklistResourceAttribute ( string $tag, string $attribute, string $value ) : boolean Return true if the resource is not blacklisted (remove blacklisted resource attributes).
filterIframeAttribute ( string $tag, string $attribute, string $value ) : boolean Return true if the iframe source is allowed (remove not allowed iframe).
filterIntegerAttribute ( string $tag, string $attribute, string $value ) : boolean Return true if the value is not integer (remove attributes that should have an integer value).
filterProtocolUrlAttribute ( string $tag, string $attribute, string $value ) : boolean Return true if the scheme is authorized.
hasRequiredAttributes ( string $tag, array $attributes ) : boolean Return true if all required attributes are present.
isAllowedProtocol ( string $value ) : boolean Detect if the protocol is allowed or not.
isBlacklistedMedia ( string $resource ) : boolean Detect if an url is blacklisted.
isResource ( string $attribute ) : boolean Check if an attribute name is an external resource.
removeYouTubeAutoplay ( string $tag, array $attribute, string &$value ) : boolean Removes YouTube autoplay from iframes.
rewriteAbsoluteUrl ( string $tag, string $attribute, string &$value ) : boolean Convert all relative links to absolute url.
rewriteImageProxyUrl ( string $tag, string $attribute, string &$value ) : boolean Rewrite image url to use with a proxy.
secureIframeSrc ( string $tag, array $attribute, string &$value ) : boolean Turns iframes' src attribute from http to https to prevent mixed active content.
setAttributeOverrides ( array $values ) : Attribute Set attributes to automatically to specific tags.
setIframeWhitelist ( array $values ) : Attribute Set allowed iframe resources.
setImageProxyCallback ( Closure $callback ) : Attribute Set image proxy callback.
setImageProxyProtocol ( string $value ) : Attribute Set image proxy protocol restriction.
setImageProxyUrl ( string $url ) : Attribute Set image proxy URL.
setIntegerAttributes ( array $values ) : Attribute Set attributes that must be an integer.
setMediaAttributes ( array $values ) : Attribute Set media attributes (used to load external resources).
setMediaBlacklist ( array $values ) : Attribute Set blacklisted external resources.
setRequiredAttributes ( array $values ) : Attribute Set mandatory attributes for whitelisted tags.
setSchemeWhitelist ( array $values ) : Attribute Set scheme whitelist.
setWhitelistedAttributes ( array $values ) : Attribute Set whitelisted tags and attributes for each tag.
toHtml ( array $attributes ) : string Convert the attribute list to html.

메소드 상세

__construct() 공개 메소드

Constructor.
public __construct ( PicoFeed\Client\Url $website )
$website PicoFeed\Client\Url Website url instance

addAttributes() 공개 메소드

Automatically add/override some attributes for specific tags.
public addAttributes ( string $tag, array $attributes ) : array
$tag string Tag name
$attributes array Attributes list
리턴 array

filter() 공개 메소드

Apply filters to the attributes list.
public filter ( string $tag, array $attributes ) : array
$tag string Tag name
$attributes array Attributes dictionary
리턴 array Filtered attributes

filterAllowedAttribute() 공개 메소드

Return true if the value is allowed (remove not allowed attributes).
public filterAllowedAttribute ( string $tag, string $attribute, string $value ) : boolean
$tag string Tag name
$attribute string Attribute name
$value string Attribute value
리턴 boolean

filterBlacklistResourceAttribute() 공개 메소드

Return true if the resource is not blacklisted (remove blacklisted resource attributes).
public filterBlacklistResourceAttribute ( string $tag, string $attribute, string $value ) : boolean
$tag string Tag name
$attribute string Attribute name
$value string Attribute value
리턴 boolean

filterIframeAttribute() 공개 메소드

Return true if the iframe source is allowed (remove not allowed iframe).
public filterIframeAttribute ( string $tag, string $attribute, string $value ) : boolean
$tag string Tag name
$attribute string Attribute name
$value string Attribute value
리턴 boolean

filterIntegerAttribute() 공개 메소드

Return true if the value is not integer (remove attributes that should have an integer value).
public filterIntegerAttribute ( string $tag, string $attribute, string $value ) : boolean
$tag string Tag name
$attribute string Attribute name
$value string Attribute value
리턴 boolean

filterProtocolUrlAttribute() 공개 메소드

Return true if the scheme is authorized.
public filterProtocolUrlAttribute ( string $tag, string $attribute, string $value ) : boolean
$tag string Tag name
$attribute string Attribute name
$value string Attribute value
리턴 boolean

hasRequiredAttributes() 공개 메소드

Return true if all required attributes are present.
public hasRequiredAttributes ( string $tag, array $attributes ) : boolean
$tag string Tag name
$attributes array Attributes list
리턴 boolean

isAllowedProtocol() 공개 메소드

Detect if the protocol is allowed or not.
public isAllowedProtocol ( string $value ) : boolean
$value string Attribute value
리턴 boolean

isBlacklistedMedia() 공개 메소드

Detect if an url is blacklisted.
public isBlacklistedMedia ( string $resource ) : boolean
$resource string Attribute value (URL)
리턴 boolean

isResource() 공개 메소드

Check if an attribute name is an external resource.
public isResource ( string $attribute ) : boolean
$attribute string Attribute name
리턴 boolean

removeYouTubeAutoplay() 공개 메소드

Removes YouTube autoplay from iframes.
public removeYouTubeAutoplay ( string $tag, array $attribute, string &$value ) : boolean
$tag string Tag name
$attribute array Atttributes name
$value string Attribute value
리턴 boolean

rewriteAbsoluteUrl() 공개 메소드

Convert all relative links to absolute url.
public rewriteAbsoluteUrl ( string $tag, string $attribute, string &$value ) : boolean
$tag string Tag name
$attribute string Attribute name
$value string Attribute value
리턴 boolean

rewriteImageProxyUrl() 공개 메소드

Rewrite image url to use with a proxy.
public rewriteImageProxyUrl ( string $tag, string $attribute, string &$value ) : boolean
$tag string Tag name
$attribute string Attribute name
$value string Attribute value
리턴 boolean

secureIframeSrc() 공개 메소드

Turns iframes' src attribute from http to https to prevent mixed active content.
public secureIframeSrc ( string $tag, array $attribute, string &$value ) : boolean
$tag string Tag name
$attribute array Atttributes name
$value string Attribute value
리턴 boolean

setAttributeOverrides() 공개 메소드

Set attributes to automatically to specific tags.
public setAttributeOverrides ( array $values ) : Attribute
$values array List of tags: ['a' => 'target="_blank"']
리턴 Attribute

setIframeWhitelist() 공개 메소드

Set allowed iframe resources.
public setIframeWhitelist ( array $values ) : Attribute
$values array List of tags: ['http://www.youtube.com']
리턴 Attribute

setImageProxyCallback() 공개 메소드

Set image proxy callback.
public setImageProxyCallback ( Closure $callback ) : Attribute
$callback Closure
리턴 Attribute

setImageProxyProtocol() 공개 메소드

Set image proxy protocol restriction.
public setImageProxyProtocol ( string $value ) : Attribute
$value string
리턴 Attribute

setImageProxyUrl() 공개 메소드

The original image url will be urlencoded
public setImageProxyUrl ( string $url ) : Attribute
$url string Proxy URL
리턴 Attribute

setIntegerAttributes() 공개 메소드

Set attributes that must be an integer.
public setIntegerAttributes ( array $values ) : Attribute
$values array List of tags: ['width', 'height']
리턴 Attribute

setMediaAttributes() 공개 메소드

Set media attributes (used to load external resources).
public setMediaAttributes ( array $values ) : Attribute
$values array List of values: ['src', 'href']
리턴 Attribute

setMediaBlacklist() 공개 메소드

Set blacklisted external resources.
public setMediaBlacklist ( array $values ) : Attribute
$values array List of tags: ['http://google.com/', '...']
리턴 Attribute

setRequiredAttributes() 공개 메소드

Set mandatory attributes for whitelisted tags.
public setRequiredAttributes ( array $values ) : Attribute
$values array List of tags: ['img' => 'src']
리턴 Attribute

setSchemeWhitelist() 공개 메소드

Set scheme whitelist.
public setSchemeWhitelist ( array $values ) : Attribute
$values array List of scheme: ['http://', 'ftp://']
리턴 Attribute

setWhitelistedAttributes() 공개 메소드

Set whitelisted tags and attributes for each tag.
public setWhitelistedAttributes ( array $values ) : Attribute
$values array List of tags: ['video' => ['src', 'cover'], 'img' => ['src']]
리턴 Attribute

toHtml() 공개 메소드

Convert the attribute list to html.
public toHtml ( array $attributes ) : string
$attributes array Attributes
리턴 string