mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-28 12:18:25 +00:00
LibWeb: Calculate hidden password text using code-point count
This means that an `<input type=password>` will show the correct number of *s in it when non-ASCII characters are entered. We also don't need to perform text-transform on these as that doesn't affect the output length, so I've moved it earlier.
This commit is contained in:
committed by
Andreas Kling
parent
3a71b8cda3
commit
c747b1c6b5
@@ -321,6 +321,11 @@ String const& TextNode::text_for_rendering() const
|
||||
// NOTE: This collapses whitespace into a single ASCII space if the CSS white-space property tells us to.
|
||||
void TextNode::compute_text_for_rendering()
|
||||
{
|
||||
if (dom_node().is_password_input()) {
|
||||
m_text_for_rendering = MUST(String::repeated('*', dom_node().data().code_points().length()));
|
||||
return;
|
||||
}
|
||||
|
||||
bool collapse = [](CSS::WhiteSpace white_space) {
|
||||
switch (white_space) {
|
||||
case CSS::WhiteSpace::Normal:
|
||||
@@ -345,11 +350,6 @@ void TextNode::compute_text_for_rendering()
|
||||
|
||||
auto data_view = data.bytes_as_string_view();
|
||||
|
||||
if (dom_node().is_password_input()) {
|
||||
m_text_for_rendering = MUST(String::repeated('*', data_view.length()));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!collapse || data.is_empty()) {
|
||||
m_text_for_rendering = data;
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user