Exemplo n.º 1
0
 /**
  * Validates that the revised contents are valid JSON.
  * If not valid, rejects edit with error message.
  * @param EditPage $editor
  * @param string $text: Content of the revised article.
  * @param string &$error: Error message to return.
  * @param string $summary: Edit summary provided for edit.
  * @return True
  */
 static function onEditFilterMerged($editor, $text, &$error, $summary)
 {
     if ($editor->getTitle()->getNamespace() !== NS_SCHEMA) {
         return true;
     }
     $content = new JsonSchemaContent($text);
     try {
         $content->validate();
     } catch (JsonSchemaException $e) {
         $error = $e->getMessage();
     }
     return true;
 }
Exemplo n.º 2
0
 /**
  * Tests JSON->HTML representation.
  * @covers JsonSchemaContent::getHighlightHtml
  */
 function testGetHighlightHtml()
 {
     $evil = new JsonSchemaContent(self::EVIL_JSON);
     $html = $evil->getHighlightHtml();
     $this->assertContains('<script>', $html, 'HTML output should be escaped');
 }