mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-29 12:19:54 +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:
parent
3a71b8cda3
commit
c747b1c6b5
Notes:
github-actions[bot]
2024-11-14 19:35:54 +00:00
Author: https://github.com/AtkinsSJ
Commit: c747b1c6b5
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2347
3 changed files with 26 additions and 5 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue