diff --git a/extlib/Mf2/Parser.php b/extlib/Mf2/Parser.php index 04d44e2aca..27805f2324 100644 --- a/extlib/Mf2/Parser.php +++ b/extlib/Mf2/Parser.php @@ -69,7 +69,7 @@ function fetch($url, $convertClassic = true, &$curlInfo=null) { curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_MAXREDIRS, 5); - $response = curl_exec($ch); + $html = curl_exec($ch); $info = $curlInfo = curl_getinfo($ch); curl_close($ch); @@ -78,7 +78,6 @@ function fetch($url, $convertClassic = true, &$curlInfo=null) { return null; } - $html = mb_substr($response, $info['header_size']); return parse($html, $url, $convertClassic); } @@ -123,12 +122,14 @@ function unicodeTrim($str) { * @return string|array The prefixed name of the first microfomats class found or false */ function mfNamesFromClass($class, $prefix='h-') { - $class = str_replace([' ', ' ', "\n"], ' ', $class); + $class = str_replace(array(' ', ' ', "\n"), ' ', $class); $classes = explode(' ', $class); $matches = array(); foreach ($classes as $classname) { - if (strpos($classname, $prefix) === 0 && $classname !== $prefix) { + $compare_classname = strtolower(' ' . $classname); + $compare_prefix = strtolower(' ' . $prefix); + if (stristr($compare_classname, $compare_prefix) !== false && ($compare_classname != $compare_prefix)) { $matches[] = ($prefix === 'h-') ? $classname : substr($classname, strlen($prefix)); } } @@ -149,10 +150,11 @@ function nestedMfPropertyNamesFromClass($class) { $prefixes = array('p-', 'u-', 'dt-', 'e-'); $propertyNames = array(); - $class = str_replace([' ', ' ', "\n"], ' ', $class); + $class = str_replace(array(' ', ' ', "\n"), ' ', $class); foreach (explode(' ', $class) as $classname) { foreach ($prefixes as $prefix) { - if (strpos($classname, $prefix) === 0 and $classname !== $prefix) { + $compare_classname = strtolower(' ' . $classname); + if (stristr($compare_classname, $prefix) && ($compare_classname != $prefix)) { $propertyNames = array_merge($propertyNames, mfNamesFromClass($classname, ltrim($prefix))); } } @@ -191,7 +193,7 @@ function convertTimeFormat($time) { preg_match('/(\d{1,2}):?(\d{2})?:?(\d{2})?(a\.?m\.?|p\.?m\.?)?/i', $time, $matches); // if no am/pm specified - if ( empty($matches[4]) ) { + if (empty($matches[4])) { return $time; } // else am/pm specified @@ -202,31 +204,27 @@ function convertTimeFormat($time) { $hh = $matches[1]; // add 12 to the pm hours - if ( $meridiem == 'pm' && ($hh < 12) ) - { + if ($meridiem == 'pm' && ($hh < 12)) { $hh += 12; } $hh = str_pad($hh, 2, '0', STR_PAD_LEFT); // minutes - $mm = ( empty($matches[2]) ) ? '00' : $matches[2]; + $mm = (empty($matches[2]) ) ? '00' : $matches[2]; // seconds, only if supplied - if ( !empty($matches[3]) ) - { + if (!empty($matches[3])) { $ss = $matches[3]; } - if ( empty($ss) ) { + if (empty($ss)) { return sprintf('%s:%s', $hh, $mm); } else { return sprintf('%s:%s:%s', $hh, $mm, $ss); } - } - } /** @@ -293,6 +291,11 @@ class Parser { } break; } + + // Ignore