Remove HTML entities when generate the URL base on title, fix for #1428

This commit is contained in:
Diego Najar 2022-05-03 20:27:30 +02:00
parent a3abf8e135
commit 299c334655
2 changed files with 16 additions and 6 deletions

View file

@ -126,6 +126,13 @@ class Text {
return str_replace(array_keys($replace), array_values($replace), $text);
}
// Remove HTML entities from the string
// HTML entities: & " ' < >
public static function removeHTMLEntities($string)
{
return preg_replace("/&#?[a-z0-9]+;/i", "", $string);
}
public static function removeSpecialCharacters($string, $replace='')
{
return preg_replace("/[\/_|+:!@#$%^&*()'\"<>\\\`}{;=,?\[\]~. -]+/", $replace, $string);
@ -156,6 +163,8 @@ class Text {
{
global $L;
$string = self::removeHTMLEntities($string);
if (EXTREME_FRIENDLY_URL && $allowExtremeFriendlyURL) {
$string = self::lowercase($string);
$string = trim($string, $separator);
@ -176,6 +185,7 @@ class Text {
}
}
// Clean
$string = preg_replace("/[^a-zA-Z0-9\/_|+. -]/", '', $string);
$string = self::lowercase($string);
$string = preg_replace("/[\/_|+ -]+/", $separator, $string);

View file

@ -9,18 +9,18 @@ $examples = array(
'description' => 'A warm welcome to your new website.',
'tags' => array('Welcome', 'Plugins', 'Themes', 'Bludit'),
'content' =>
'<p>Thanks for chose Bludit and welcome to our community, we are growing up everyday and is awesome.</p>
<p>Follow Bludit in different social networks:</p>
'<p>Thank you for choosing Bludit and welcome to our community, we are growing every day and it\'s amazing.</p>
<p>Follow Bludit on different social networks:</p>
<ul>
<li><a href="https://twitter.com/bludit">https://twitter.com/bludit</a></li>
<li><a href="https://www.facebook.com/bluditcms">https://www.facebook.com/bluditcms</a></li>
</ul>
<p>Take a look to the plugins and themes:</p>
<p>Take a look at the plugins and themes:</p>
<ul>
<li><a href="https://plugins.bludit.com">https://plugins.bludit.com</a></li>
<li><a href="https://themes.bludit.com">https://themes.bludit.com</a></li>
</ul>
<p>Do you need support or you want to read about Bludit, check our official documentation or participate in our forum.</p>
<p>Do you need support? or want to read about Bludit, consult our official documentation or participate in our forum</p>
<ul>
<li><a href="https://forum.bludit.org">https://forum.bludit.org</a></li>
<li><a href="https://docs.bludit.com">https://docs.bludit.com</a></li>
@ -36,7 +36,7 @@ $examples = array(
'tags' => array('Language', 'Timezone', 'Markdown', 'Bludit'),
'content' =>
'<h2>Site information</h2>
<p>Improve your site information and metadata. Include a site description to refine your ranking on the search engines, add social networks, include a site logo with your brand.</p>
<p>Improve your site information and metadata. Include a site description to refine your ranking on the search engines, add social networks, and include a site logo with your brand.</p>
<h2>Language and Timezone</h2>
<p>Bludit supports a variety of languages and time zones. Choose the option that best suits you and your visitors.</p>
<h2>Admin panel</h2>
@ -48,7 +48,7 @@ $examples = array(
<p>Bludit supports Markdown, you just need to enable the right editor to work with it.</p>
<ol>
<li>Go to the Admin panel</li>
<li>Go to Plugins section</li>
<li>Go to the plugins section</li>
<li>Disable TinyMCE plugin</li>
<li>Enable EasyMDE plugin</li>
</ol>'