Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mauvaise réécriture d'url avec liens data:image et commençant par # #174

Closed
pluxml opened this issue Apr 20, 2016 · 3 comments
Closed

Comments

@pluxml
Copy link
Collaborator

pluxml commented Apr 20, 2016

Les liens de ce type sont réécrits par la méthode plxUtils::rel2abs donnant des liens invalides

<img src="data:image/jpeg;base64,/9j/4AAQSkZJRgA" />
donne :
<img src="http://localhost/data:image/jpeg;base64,/9j/4AAQSkZJRgA" />

Pour l'exemple <a href="#status" /> cela pose problème quand on fournit du code dans des articles (coloration syntaxique via prism.js).
On obtient <a href="http://localhost#status" />

@pluxml
Copy link
Collaborator Author

pluxml commented Apr 20, 2016

Solution:

Dans le fichier core/lib/class.plx.utils.php, fonction rel2abs, remplacer:

$patterns = array('#(href)=("|\')(mailto:|news:)#i', '#(href|src)=("|\')([a-z]+://)#i', '#(href|src)=("|\')(?:\./)?([^/])#i');
par
$patterns = array('#(href|src)=("|\')(\#|data:|mailto:|news:)#i', '#(href|src)=("|\')([a-z]+://)#i', '#(href|src)=("|\')(?:\./)?([^/])#i');

@pluxml
Copy link
Collaborator Author

pluxml commented Apr 20, 2016

même problème avec les liens

<a href="javascript:void(0)">lien</a>
réécrit en
<a href="http://localhost/javascript:void(0)">lien</a>

@pluxml
Copy link
Collaborator Author

pluxml commented Apr 20, 2016

Solution

$patterns = array('#(href|src)=("|\')(\#|javascript|data:|mailto:|news:)#i', '#(href|src)=("|\')([a-z]+://)#i', '#(href|src)=("|\')(?:\./)?([^/])#i');

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0 participants