/** * @see DataValue::parseUserValue * * @param string $value */ protected function parseUserValue($value) { if ($value === '') { $this->addErrorMsg('smw_emptystring'); } if (($this->getOptionBy('smwgDVFeatures') & SMW_DV_PVAP) == 0 && $value !== '') { $this->addErrorMsg(array('smw-datavalue-feature-not-supported', 'Allows pattern (SMW_DV_PVAP)')); } $content = $this->allowsPatternContentParser->parse($value); if (!$content) { $this->addErrorMsg(array('smw-datavalue-allows-pattern-reference-unknown', $value), Message::PARSE); } parent::parseUserValue($value); }
/** * @since 2.4 * * {@inheritDoc} */ public function validate($dataValue) { $this->hasConstraintViolation = false; if (!$dataValue instanceof DataValue || $dataValue->getProperty() === null || !$dataValue->isEnabledFeature(SMW_DV_PVAP)) { return $this->hasConstraintViolation; } if (($reference = ApplicationFactory::getInstance()->getPropertySpecificationLookup()->getAllowedPatternBy($dataValue->getProperty())) === '') { return $this->hasConstraintViolation; } $content = $this->allowsPatternContentParser->parse($reference); if (!$content) { return $this->hasConstraintViolation; } // Prevent a possible remote code execution vulnerability in connection // with PCRE $pattern = str_replace(array('/e'), array(''), trim($content)); $this->doPregMatch($pattern, $dataValue, $reference); }