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

For HTML messages, add HTML tags to all URIs in message footer/header text #1916

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

adam12b1
Copy link

Use URI::Find::Schemeless to add HTML tags around all URIs in message footer/header text, so links are clickable when text is appended to HTML messages. No effect on plaintext messages.

…ssage footer/header text, so links are clickable when text is appended to HTML messages
@@ -63,6 +63,8 @@ use Sympa::Tools::Password;
use Sympa::Tools::SMIME;
use Sympa::Tools::Text;
use Sympa::User;
use CGI;
use URI::Find::Schemeless;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

URI::Find::Schemeless should also be added to the cpanfile file on the top of source tree as a requires section.

$footer_msg = Sympa::Tools::Text::encode_html($footer_msg);
$footer_msg = uri_finder($footer_msg);
Copy link
Member

@ikedas ikedas Jan 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HTML encoding (escaping) should be done only in uri_finder() below, i.e. Sympa::Tools::Text::encode_html() in above line should be removed. Or escaping will duplicate (and URIs including & will not be detected properly).

The same is true for $header_msg and $global_footer_msg.

my($uri, $orig_uri) = @_;
return qq|<a href="$uri">$orig_uri</a>|;
});
$finder->find(\$text, \&CGI::escapeHTML);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use Sympa::Tools::Text::escape_html() instead of CGI::encodeHTML(). The reason is simply that Sympa consistently uses the former.

$finder->find(\$text, \&CGI::escapeHTML);

# and finally clean up the displayed link text on mailto links:
$text =~ s/>mailto:/>/g;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I personally think that this “mailto:” is included in the original text and may not be removed.

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

Successfully merging this pull request may close these issues.

2 participants