From 024059b49b0539dc7fbd87624f6369645b247480 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sun, 13 Dec 2020 18:20:50 +0100 Subject: [PATCH] LibTextCodec: Normalize incoming encodings in decoder_for() Instead of asserting when you call TextCoded::decoder_for() with a non-standard encoding name, let's be nice and see if we can't find a decoder for the standardized version of the encoding name. --- Libraries/LibTextCodec/Decoder.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Libraries/LibTextCodec/Decoder.cpp b/Libraries/LibTextCodec/Decoder.cpp index 3ce651ade5..afcb8cd6ee 100644 --- a/Libraries/LibTextCodec/Decoder.cpp +++ b/Libraries/LibTextCodec/Decoder.cpp @@ -46,14 +46,14 @@ static UTF8Decoder& utf8_decoder() return *decoder; } -Decoder* decoder_for(const String& encoding) +Decoder* decoder_for(const String& a_encoding) { - ASSERT(is_standardized_encoding(encoding)); + auto encoding = get_standardized_encoding(a_encoding); if (encoding.equals_ignoring_case("windows-1252")) return &latin1_decoder(); if (encoding.equals_ignoring_case("utf-8")) return &utf8_decoder(); - dbg() << "TextCodec: No decoder implemented for encoding '" << encoding << "'"; + dbgln("TextCodec: No decoder implemented for encoding '{}'", a_encoding); return nullptr; }