Skip to content
Extraits de code Groupes Projets
Valider 16538e30 rédigé par Fil's avatar Fil
Parcourir les fichiers

s'assurer de la compliance des microformats a[rel='enclosure'], en changeant...

s'assurer de la compliance des microformats a[rel='enclosure'], en changeant length en title (idee d'ESJ) ; leve un bug de htmlpurifier qui tue a[rel]
parent e402cedd
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -1394,31 +1394,35 @@ function afficher_tags($tags, $rels='tag,directory') { ...@@ -1394,31 +1394,35 @@ function afficher_tags($tags, $rels='tag,directory') {
// Passe un <enclosure url="fichier" length="5588242" type="audio/mpeg"/> // Passe un <enclosure url="fichier" length="5588242" type="audio/mpeg"/>
// au format microformat <a rel="enclosure" href="fichier" ...>fichier</a> // au format microformat <a rel="enclosure" href="fichier" ...>fichier</a>
// attention length="zz" devient title="zz", pour rester conforme
// http://doc.spip.org/@enclosure2microformat // http://doc.spip.org/@enclosure2microformat
function enclosure2microformat($e) { function enclosure2microformat($e) {
$url = extraire_attribut($e, 'url'); $url = filtrer_entites(extraire_attribut($e, 'url'));
$fichier = basename($url) OR $fichier; $type = extraire_attribut($e, 'type');
$e = preg_replace(',<enclosure[[:space:]],iS','<a rel="enclosure" ', $e) $length = extraire_attribut($e, 'length');
. $fichier.'</a>'; $fichier = basename($url);
$e = vider_attribut($e, 'url'); return '<a rel="enclosure"'
$e = inserer_attribut($e, 'href', filtrer_entites($url)); . ($url? ' href="'.htmlspecialchars($url).'"' : '')
$e = str_replace('/>', '>', $e); . ($type? ' type="'.htmlspecialchars($type).'"' : '')
return $e; . ($length? ' title="'.htmlspecialchars($length).'"' : '')
. '>'.$fichier.'</a>';
} }
// La fonction inverse // La fonction inverse
// http://doc.spip.org/@microformat2enclosure // http://doc.spip.org/@microformat2enclosure
function microformat2enclosure($tags) { function microformat2enclosure($tags) {
$enclosures = array(); $enclosures = array();
foreach (extraire_tags($tags) as $e) foreach (extraire_tags($tags) as $e)
if (extraire_attribut($e, rel) == 'enclosure') { if (extraire_attribut($e, 'rel') == 'enclosure') {
$url = extraire_attribut($e, 'href'); $url = filtrer_entites(extraire_attribut($e, 'href'));
$fichier = basename($url) OR $fichier; $type = extraire_attribut($e, 'type');
$e = preg_replace(',<a[[:space:]],iS','<enclosure ', $e); if (!$length = intval(extraire_attribut($e, 'title')))
$e = preg_replace(',( ?/?)>.*,S',' />', $e); $length = intval(extraire_attribut($e, 'length')); # vieux data
$e = vider_attribut($e, 'href'); $fichier = basename($url);
$e = vider_attribut($e, 'rel'); $enclosures[] = '<enclosure'
$e = inserer_attribut($e, 'url', filtrer_entites($url)); . ($url? ' url="'.htmlspecialchars($url).'"' : '')
$enclosures[] = $e; . ($type? ' type="'.htmlspecialchars($type).'"' : '')
. ($length? ' length="'.$length.'"' : '')
. ' />';
} }
return join("\n", $enclosures); return join("\n", $enclosures);
} }
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter