django-cms / djangocms-text-ckeditor

Text Plugin for django CMS using CKEditor 4
https://www.django-cms.org/en/repositories-plugins/
BSD 3-Clause "New" or "Revised" License
167 stars 185 forks source link

add tel hyperlinks not working #638

Closed i-salameh95 closed 1 year ago

i-salameh95 commented 1 year ago

Hello, I have noticed that adding telephone links inside djangocms-text-ckeditor is wrapping the output link: for example:

<span class="pbmit-footer-contact-info-wrap"><span class="pbmit-label pbmit-label-1">contact by phone:</span>
<a href="tel: 0097092331471"> +97092331471</a></span>

Then the outputed link appear without href at all. this happened with tel link only. djangocms-text-ckeditor version used: 5.1.1 django cms version: 3.11

fsbraun commented 1 year ago

This is a bug of the html sanitizer. It needs rework anyway. For the time being. I'd suggest to use a Link plugin (e.g., djangocms-frontend's) and enter the phone link. This will render correctly.

petrklus commented 1 year ago

@fsbraun @i-salameh95 there is also another fix - you can put TEXT_ADDITIONAL_PROTOCOLS setting into your settings.py and add the missing protocol.

This line fixed the issue for me:

TEXT_ADDITIONAL_PROTOCOLS = ["tel"]

Though I agree this is a bug - one would expect that the default options in the text editor would all be allowed.

To verify all is working correctly, as simple test below:

from djangocms_text_ckeditor.html import clean_html

test_html = """<p>Here is a tel link <a href="tel:54423234">helo</a></p>"""

clean_html(test_html)
stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

petrklus commented 1 year ago

Any thoughts on the above? Perhaps the tel protocol should be added by default?

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] commented 1 year ago

This will now be closed due to inactivity, but feel free to reopen it.