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

改善多行个人说明文本显示 #975

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions author.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<h3><?php the_author(); ?></h3>
<div class="description">
<?php
$description = get_the_author_meta('description');
$description = htmlspecialchars(get_the_author_meta('description'), ENT_QUOTES, 'UTF-8');
echo $description ? nl2br($description) : __("No personal profile set yet", "sakurairo");
?>
</div>
Expand Down Expand Up @@ -63,4 +63,4 @@

<?php
get_footer();
?>
?>
6 changes: 3 additions & 3 deletions style.css
Original file line number Diff line number Diff line change
Expand Up @@ -1577,7 +1577,7 @@ h1.page-title {
max-width: 70%;
width: fit-content;
position: relative;
height: 110px;
 min-height: 110px;
left: 50%;
transform: translateX(-50%);
margin: 10% 0;
Expand Down Expand Up @@ -1636,8 +1636,8 @@ h1.page-title {
font-size: 14px;
font-weight: var(--global-font-weight);
text-align: center;
overflow: hidden;
max-height: 20px;
 overflow: auto;
KotoriK marked this conversation as resolved.
Show resolved Hide resolved
max-height: 400px;
height: fit-content;
margin: 0 10px;
}
Expand Down
5 changes: 4 additions & 1 deletion tpl/section-article-function.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,12 @@
if (empty($author_description)) {
$author_description = __('This author has not provided a description.', 'sakurairo');
}
// 对描述内容进行转义,防止XSS攻击
$safe_description = htmlspecialchars($author_description, ENT_QUOTES, 'UTF-8');
Copy link
Collaborator

Choose a reason for hiding this comment

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

为什么要设置$flags?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

因已有代码进行空字符串判断和填充,为尽量减少对已有代码的改动,故新设置变量$safe_description

Copy link
Collaborator

Choose a reason for hiding this comment

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

但你只设置ENT_QUOTES而不设置HTML实体的FLAG的话实现不了你注释的效果吧

?>
<div class="desc">
<i class="fa-solid fa-feather" aria-hidden="true"></i><?= $author_description; ?>
<i class="fa-solid fa-feather" aria-hidden="true"></i>
<?php echo nl2br($safe_description);?>
</div>
<?php } ?>
</section>
Expand Down