ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
enshrined\svgSanitize\ElementReference\Resolver Class Reference
+ Collaboration diagram for enshrined\svgSanitize\ElementReference\Resolver:

Public Member Functions

 __construct (XPath $xPath, $useNestingLimit)
 
 collect ()
 
 findByElement (\DOMElement $element, $considerChildren=false)
 Resolves one subject by element. More...
 
 findByElementId ($elementId)
 Resolves subjects (plural!) by element id - in theory malformed DOM might have same ids assigned to different elements and leaving it to client/browser implementation which element to actually use. More...
 
 getElementsToRemove ()
 Get all the elements that caused a nesting exception. More...
 

Protected Member Functions

 determineInvalidSubjects ()
 Determines and tags infinite loops. More...
 
 markSubjectAsInvalid (Subject $subject)
 The Subject is invalid for some reason, therefore we should remove it and all it's child usages. More...
 

Protected Attributes

 $xPath
 
 $subjects = []
 
 $elementsToRemove = []
 
 $useNestingLimit
 

Detailed Description

Definition at line 8 of file Resolver.php.

Constructor & Destructor Documentation

◆ __construct()

enshrined\svgSanitize\ElementReference\Resolver::__construct ( XPath  $xPath,
  $useNestingLimit 
)

Member Function Documentation

◆ collect()

enshrined\svgSanitize\ElementReference\Resolver::collect ( )

Definition at line 36 of file Resolver.php.

References enshrined\svgSanitize\ElementReference\Resolver\determineInvalidSubjects().

37  {
38  $this->collectIdentifiedElements();
39  $this->processReferences();
40  $this->determineInvalidSubjects();
41  }
determineInvalidSubjects()
Determines and tags infinite loops.
Definition: Resolver.php:123
+ Here is the call graph for this function:

◆ determineInvalidSubjects()

enshrined\svgSanitize\ElementReference\Resolver::determineInvalidSubjects ( )
protected

Determines and tags infinite loops.

Definition at line 123 of file Resolver.php.

References enshrined\svgSanitize\ElementReference\Resolver\$elementsToRemove, enshrined\svgSanitize\Helper\extractIdReferenceFromHref(), enshrined\svgSanitize\Exceptions\NestingException\getElement(), enshrined\svgSanitize\Helper\getElementHref(), and enshrined\svgSanitize\ElementReference\Resolver\markSubjectAsInvalid().

Referenced by enshrined\svgSanitize\ElementReference\Resolver\collect().

124  {
125  foreach ($this->subjects as $subject) {
126 
127  if (in_array($subject->getElement(), $this->elementsToRemove)) {
128  continue;
129  }
130 
132  Helper::getElementHref($subject->getElement())
133  );
134 
135  try {
136  if ($useId === $subject->getElementId()) {
137  $this->markSubjectAsInvalid($subject);
138  } elseif ($subject->hasInfiniteLoop()) {
139  $this->markSubjectAsInvalid($subject);
140  }
141  } catch (NestingException $e) {
142  $this->elementsToRemove[] = $e->getElement();
143  $this->markSubjectAsInvalid($subject);
144  }
145  }
146  }
static getElementHref(\DOMElement $element)
Definition: Helper.php:10
static extractIdReferenceFromHref($href)
Definition: Helper.php:25
markSubjectAsInvalid(Subject $subject)
The Subject is invalid for some reason, therefore we should remove it and all it's child usages...
Definition: Resolver.php:163
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ findByElement()

enshrined\svgSanitize\ElementReference\Resolver::findByElement ( \DOMElement  $element,
  $considerChildren = false 
)

Resolves one subject by element.

Parameters
\DOMElement$element
bool$considerChildrenWhether to search in Subject's children as well
Returns
Subject|null

Definition at line 50 of file Resolver.php.

References enshrined\svgSanitize\Helper\isElementContainedIn().

51  {
52  foreach ($this->subjects as $subject) {
53  if (
54  $element === $subject->getElement()
55  || $considerChildren && Helper::isElementContainedIn($element, $subject->getElement())
56  ) {
57  return $subject;
58  }
59  }
60  return null;
61  }
static isElementContainedIn(\DOMElement $needle, \DOMElement $haystack)
Definition: Helper.php:38
+ Here is the call graph for this function:

◆ findByElementId()

enshrined\svgSanitize\ElementReference\Resolver::findByElementId (   $elementId)

Resolves subjects (plural!) by element id - in theory malformed DOM might have same ids assigned to different elements and leaving it to client/browser implementation which element to actually use.

Parameters
string$elementId
Returns
Subject[]

Definition at line 71 of file Resolver.php.

References enshrined\svgSanitize\Helper\extractIdReferenceFromHref(), enshrined\svgSanitize\Helper\getElementHref(), and enshrined\svgSanitize\ElementReference\Subject\getElementId().

72  {
73  return array_filter(
74  $this->subjects,
75  function (Subject $subject) use ($elementId) {
76  return $elementId === $subject->getElementId();
77  }
78  );
79  }
+ Here is the call graph for this function:

◆ getElementsToRemove()

enshrined\svgSanitize\ElementReference\Resolver::getElementsToRemove ( )

Get all the elements that caused a nesting exception.

Returns
array

Definition at line 153 of file Resolver.php.

References enshrined\svgSanitize\ElementReference\Resolver\$elementsToRemove.

◆ markSubjectAsInvalid()

enshrined\svgSanitize\ElementReference\Resolver::markSubjectAsInvalid ( Subject  $subject)
protected

The Subject is invalid for some reason, therefore we should remove it and all it's child usages.

Parameters
Subject$subject

Definition at line 163 of file Resolver.php.

References enshrined\svgSanitize\ElementReference\Subject\clearInternalAndGetAffectedElements().

Referenced by enshrined\svgSanitize\ElementReference\Resolver\determineInvalidSubjects().

163  {
164  $this->elementsToRemove = array_merge(
165  $this->elementsToRemove,
166  $subject->clearInternalAndGetAffectedElements()
167  );
168  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $elementsToRemove

enshrined\svgSanitize\ElementReference\Resolver::$elementsToRemove = []
protected

◆ $subjects

enshrined\svgSanitize\ElementReference\Resolver::$subjects = []
protected

Definition at line 18 of file Resolver.php.

◆ $useNestingLimit

enshrined\svgSanitize\ElementReference\Resolver::$useNestingLimit
protected

◆ $xPath

enshrined\svgSanitize\ElementReference\Resolver::$xPath
protected

The documentation for this class was generated from the following file: