mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-05-05 06:32:30 +02:00
LibTextCodec: Support validating encoded inputs
This commit is contained in:
committed by
Andreas Kling
parent
ad4470bc39
commit
079c96376c
Notes:
sideshowbarker
2024-07-17 06:54:15 +09:00
Author: https://github.com/IdanHo Commit: https://github.com/SerenityOS/serenity/commit/079c96376c Pull-request: https://github.com/SerenityOS/serenity/pull/21968 Issue: https://github.com/SerenityOS/serenity/issues/21779
@@ -18,6 +18,7 @@ namespace TextCodec {
|
||||
class Decoder {
|
||||
public:
|
||||
virtual ErrorOr<void> process(StringView, Function<ErrorOr<void>(u32)> on_code_point) = 0;
|
||||
virtual bool validate(StringView);
|
||||
virtual ErrorOr<String> to_utf8(StringView);
|
||||
|
||||
protected:
|
||||
@@ -27,18 +28,21 @@ protected:
|
||||
class UTF8Decoder final : public Decoder {
|
||||
public:
|
||||
virtual ErrorOr<void> process(StringView, Function<ErrorOr<void>(u32)> on_code_point) override;
|
||||
virtual bool validate(StringView) override;
|
||||
virtual ErrorOr<String> to_utf8(StringView) override;
|
||||
};
|
||||
|
||||
class UTF16BEDecoder final : public Decoder {
|
||||
public:
|
||||
virtual ErrorOr<void> process(StringView, Function<ErrorOr<void>(u32)> on_code_point) override;
|
||||
virtual bool validate(StringView) override;
|
||||
virtual ErrorOr<String> to_utf8(StringView) override;
|
||||
};
|
||||
|
||||
class UTF16LEDecoder final : public Decoder {
|
||||
public:
|
||||
virtual ErrorOr<void> process(StringView, Function<ErrorOr<void>(u32)> on_code_point) override;
|
||||
virtual bool validate(StringView) override;
|
||||
virtual ErrorOr<String> to_utf8(StringView) override;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user