Пример #1
0
 /**
  * Test that assertHtml knows how to handle correct quoting.
  *
  * @return void
  */
 public function testAssertHtmlQuotes()
 {
     $input = '<a href="/test.html" class="active">My link</a>';
     $pattern = array('a' => array('href' => '/test.html', 'class' => 'active'), 'My link', '/a');
     isHtml($pattern, $input);
     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     $input = "<a href='/test.html' class='active'>My link</a>";
     $pattern = array('a' => array('href' => '/test.html', 'class' => 'active'), 'My link', '/a');
     isHtml($pattern, $input);
     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     $input = '<link rel="stylesheet" type="text/css" href="path/css/libs/font-awesome.css?387456735964" />';
     $pattern = array('link' => array('rel' => 'stylesheet', 'type' => 'text/css', 'href' => 'preg:/.*css\\/libs\\/font-awesome\\.css\\?[0-9]+/'));
     isHtml($pattern, $input);
     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     $input = "<span><strong>Text</strong></span>";
     $pattern = array('<span', '<strong', 'Text', '/strong', '/span');
     isHtml($pattern, $input);
     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     $input = "<span class='active'><strong>Text</strong></span>";
     $pattern = array('span' => array('class'), '<strong', 'Text', '/strong', '/span');
     isHtml($pattern, $input);
     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     $value = 220985;
     $input = '<p><strong>' . $value . '</strong></p>';
     $pattern = array('<p', '<strong', $value, '/strong', '/p');
     isHtml($pattern, $input);
     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     $input = '<p><strong>' . $value . '</strong></p><p><strong>' . $value . '</strong></p>';
     $pattern = array('<p', '<strong', $value, '/strong', '/p', '<p', '<strong', $value, '/strong', '/p');
     isHtml($pattern, $input);
     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     $input = '<p><strong>' . $value . '</strong></p><p id="' . $value . '"><strong>' . $value . '</strong></p>';
     $pattern = array('<p', '<strong', $value, '/strong', '/p', 'p' => array('id' => $value), '<strong', $value, '/strong', '/p');
     isHtml($pattern, $input);
     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     $input = implode('', array('<link rel="stylesheet" type="text/css" href="path/styles.css" />', '<link rel="stylesheet" type="text/css" href="path/css/libs/font-awesome.css" />'));
     $pattern = array(array('link' => array('rel' => 'stylesheet', 'href' => 'path/styles.css', 'type' => 'text/css')), array('link' => array('rel' => 'stylesheet', 'type' => 'text/css', 'href' => 'path/css/libs/font-awesome.css')));
     isHtml($pattern, $input);
 }
Пример #2
0
<?php

require "functions.php";
$uri = file_get_contents("php://input");
if (isHtml($uri)) {
    echo getSite($uri);
}
Пример #3
0
 /**
  * Asserts HTML tags.
  * @param array  $expected An array, see above
  * @param string $string   An HTML/XHTML/XML string
  * @return bool
  *
  * @deprecated See isHtml()
  */
 public function assertHtml($expected, $string)
 {
     return isHtml($expected, $string);
 }
Пример #4
-1
 function markdownify(Silex\Application $app, Request $request)
 {
     $html = $_POST['html'];
     if (isHtml($html)) {
         require_once __DIR__ . '/classes/markdownify/markdownify_extra.php';
         $md = new Markdownify(false, 80, false);
         $output = $md->parseString($html);
     } else {
         $output = $html;
     }
     echo $output;
 }
Пример #5
-1
 public function markdownify(Silex\Application $app, Request $request)
 {
     $html = $request->request->get('html');
     if (isHtml($html)) {
         require_once __DIR__ . '/../../../classes/markdownify/markdownify_extra.php';
         $markdown = new \Markdownify(false, 80, false);
         $output = $markdown->parseString($html);
     } else {
         $output = $html;
     }
     return $output;
 }