mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 15:57:35 +00:00
AK: Use an enum instead of a bool for String::replace(all_occurences)
This commit has no behavior changes. In particular, this does not fix any of the wrong uses of the previous default parameter (which used to be 'false', meaning "only replace the first occurence in the string"). It simply replaces the default uses by String::replace(..., ReplaceMode::FirstOnly), leaving them incorrect.
This commit is contained in:
parent
b2454888e8
commit
7ceeb74535
47 changed files with 108 additions and 102 deletions
|
@ -2883,7 +2883,7 @@ Optional<UnicodeRange> Parser::parse_unicode_range(StringView text)
|
|||
// 2. Interpret the consumed code points as a hexadecimal number,
|
||||
// with the U+003F QUESTION MARK (?) code points replaced by U+0030 DIGIT ZERO (0) code points.
|
||||
// This is the start value.
|
||||
auto start_value_string = start_value_code_points.replace("?", "0", true);
|
||||
auto start_value_string = start_value_code_points.replace("?", "0", ReplaceMode::All);
|
||||
auto maybe_start_value = AK::StringUtils::convert_to_uint_from_hex<u32>(start_value_string);
|
||||
if (!maybe_start_value.has_value()) {
|
||||
dbgln_if(CSS_PARSER_DEBUG, "CSSParser: <urange> ?-converted start value did not parse as hex number.");
|
||||
|
@ -2894,7 +2894,7 @@ Optional<UnicodeRange> Parser::parse_unicode_range(StringView text)
|
|||
// 3. Interpret the consumed code points as a hexadecimal number again,
|
||||
// with the U+003F QUESTION MARK (?) code points replaced by U+0046 LATIN CAPITAL LETTER F (F) code points.
|
||||
// This is the end value.
|
||||
auto end_value_string = start_value_code_points.replace("?", "F", true);
|
||||
auto end_value_string = start_value_code_points.replace("?", "F", ReplaceMode::All);
|
||||
auto maybe_end_value = AK::StringUtils::convert_to_uint_from_hex<u32>(end_value_string);
|
||||
if (!maybe_end_value.has_value()) {
|
||||
dbgln_if(CSS_PARSER_DEBUG, "CSSParser: <urange> ?-converted end value did not parse as hex number.");
|
||||
|
|
|
@ -276,16 +276,16 @@ static DOM::ExceptionOr<String> serialize_an_attribute_value(String const& attri
|
|||
auto final_attribute_value = attribute_value;
|
||||
|
||||
// 1. "&" with "&"
|
||||
final_attribute_value = final_attribute_value.replace("&"sv, "&"sv, true);
|
||||
final_attribute_value = final_attribute_value.replace("&"sv, "&"sv, ReplaceMode::All);
|
||||
|
||||
// 2. """ with """
|
||||
final_attribute_value = final_attribute_value.replace("\""sv, """sv, true);
|
||||
final_attribute_value = final_attribute_value.replace("\""sv, """sv, ReplaceMode::All);
|
||||
|
||||
// 3. "<" with "<"
|
||||
final_attribute_value = final_attribute_value.replace("<"sv, "<"sv, true);
|
||||
final_attribute_value = final_attribute_value.replace("<"sv, "<"sv, ReplaceMode::All);
|
||||
|
||||
// 4. ">" with ">"
|
||||
final_attribute_value = final_attribute_value.replace(">"sv, ">"sv, true);
|
||||
final_attribute_value = final_attribute_value.replace(">"sv, ">"sv, ReplaceMode::All);
|
||||
|
||||
return final_attribute_value;
|
||||
}
|
||||
|
@ -736,13 +736,13 @@ static DOM::ExceptionOr<String> serialize_text(DOM::Text const& text, [[maybe_un
|
|||
String markup = text.data();
|
||||
|
||||
// 3. Replace any occurrences of "&" in markup by "&".
|
||||
markup = markup.replace("&"sv, "&"sv, true);
|
||||
markup = markup.replace("&"sv, "&"sv, ReplaceMode::All);
|
||||
|
||||
// 4. Replace any occurrences of "<" in markup by "<".
|
||||
markup = markup.replace("<"sv, "<"sv, true);
|
||||
markup = markup.replace("<"sv, "<"sv, ReplaceMode::All);
|
||||
|
||||
// 5. Replace any occurrences of ">" in markup by ">".
|
||||
markup = markup.replace(">"sv, ">"sv, true);
|
||||
markup = markup.replace(">"sv, ">"sv, ReplaceMode::All);
|
||||
|
||||
// 6. Return the value of markup.
|
||||
return markup;
|
||||
|
|
|
@ -54,7 +54,7 @@ Vector<QueryParam> url_decode(StringView input)
|
|||
}
|
||||
|
||||
// 4. Replace any 0x2B (+) in name and value with 0x20 (SP).
|
||||
auto space_decoded_name = name.replace("+"sv, " "sv, true);
|
||||
auto space_decoded_name = name.replace("+"sv, " "sv, ReplaceMode::All);
|
||||
|
||||
// 5. Let nameString and valueString be the result of running UTF-8 decode without BOM on the percent-decoding of name and value, respectively.
|
||||
auto name_string = AK::URL::percent_decode(space_decoded_name);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue