Skip to content

[BUG] Incorrect display of escaped HTML code. #1353

@pishguy

Description

@pishguy

When I save an HTML page in the database and call it using the URL below, I receive the text in escaped HTML code:

╔╣ Response ║ GET ║ Status: 200 OK
║  http://192.168.1.220/api/v1/static-pages/about-us
╚═══════════════════════════════════════╝
╔ Headers 
╟ connection: [keep-alive]
╟ x-powered-by: [PHP/8.2.8]
╟ cache-control: [no-cache, private]
╟ access-control-allow-origin: [*]
╟ x-ratelimit-limit: [60]
╟ transfer-encoding: [chunked]
╟ date: [Fri, 04 Aug 2023 15:27:51 GMT]
╟ x-ratelimit-remaining: [59]
╟ content-type: [application/json]
╟ server: [nginx]
╚═══════════════════════════════════════╝
╔ Body
║
║ "<p>about us<\/p>"
║
╚════════════════════════════════════════╝

When I want to display this HTML code using the code below, it shows the screenshot below:

Screenshot_20230804_190023

Code I have implemented:

class AboutUsWidget extends ElementaryWidget<IAboutUsWidgetModel> {
  const AboutUsWidget({
    Key? key,
    WidgetModelFactory wmFactory = defaultAboutUsWidgetModelFactory,
  }) : super(wmFactory, key: key);

  @override
  Widget build(IAboutUsWidgetModel wm) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: DefaultColors.$darkBlue,
        titleSpacing: 0.0,
        title: Center(
          child: Text(LocaleKeys.about_us.tr()),
        ),
      ),
      body: EntityStateNotifierBuilder<String>(
        listenableEntityState: wm.aboutUsHtml,
        loadingBuilder: (_, __) => const LoadingWidget(),
        errorBuilder: (_, Exception? error, __) {
          return const Text('Please Try Again');
        },
        builder: (_, String? data) {
          print('=> $data');
          return ListView(
            children: [
              Html(
                data: data,
              )
            ],
          );
        },
      ),
    );
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions