What are the built-in cleanup tools of AnQiCMS when processing HTML content from external sources?

Calendar 👁️ 75

When processing HTML content collected from external sources, AnQiCMS (AnQiCMS) provides a series of built-in cleaning tools and strategies to help users efficiently manage and optimize content, ensuring the quality, security, and display effects of the website content.These features provide comprehensive support from the automated processing before content is stored to the refined control during content display.

Content optimization and security filtering before storage

When external HTML content enters the system through the "Content Collection and Bulk Import" feature, Anqi CMS will perform multiple automatic or manual configuration purification processes before storing the content:

  1. Remote image localization and optimization

    • Download remote image:Many collection contents refer to images from external servers. Anqi CMS supports automatically downloading these remote images to the local server, solving problems such as invalid external image links and slow loading, and also avoids the situation where images cannot be displayed due to issues with external servers, ensuring the integrity of the content.
    • WebP format conversion and automatic compression:To further optimize website performance, Anqi CMS can be configured to automatically convert images during upload (including remote images downloaded after collection) to WebP format and automatically compress large images.This can significantly reduce the size of image files, speed up page loading, improve user experience, and save storage space.These processes ensure that the image resources of the collected content are optimized to the maximum extent upon entry.
  2. External link filtering and processing

    • The collected HTML content often contains a large number of external links, which may have a negative impact on SEO or lead to unsafe content.The AnQi CMS provides the option to 'Automatically filter external links'.If you choose to filter, the system will directly remove these external links.If you do not select filtering, the system will also automatically add external links torel="nofollow"Attribute, this helps indicate to search engines not to track these links, thus better controlling the flow of website SEO weight.
    • Sensitive word filtering:As part of content security management, Anqi CMS has built-in sensitive word filtering functionality.This means that when content is collected and stored, the system will automatically detect and handle preset sensitive words (such as replacing or blocking them), ensuring the compliance of website content and reducing operational risks.
  3. Batch content replacement and correction

    • The "Full Site Content Replacement" and "Article Content Bulk Replacement" features are powerful cleaning tools.Users can use these features to perform large-scale text replacement operations on collected content.For example, remove specific ad information, standardize certain wording, correct common typesetting errors, and even use regular expressions to match and clear complex HTML fragments or bad style codes.This is very useful for scenarios such as unifying content style, removing redundant information, and correcting format errors.

精细化控制渲染输出时的内容

In addition to the purification before storage, the Anqi CMS also provides a more flexible and detailed purification capability through template tags and filters when the content is finally rendered on the web page, ensuring the purity and safety of the front-end display:

  1. Remove and Control of HTML Tags

    • striptagsFilter:This filter can remove all HTML tags from the HTML content and retain only plain text.This is very useful when it is necessary to extract plain text summaries from complex HTML or to ensure that content is displayed in the simplest form.
    • removetagsFilter:If you just want to remove specific tags (such as<i>or<font>tags, while keeping other tags),removetagsThe filter can accurately meet this requirement, it allows specifying one or more tags to be removed.
  2. Escape special characters and display safely

    • escapeandeFilter:By default, the template engine of AnQi CMS automatically escapes the output HTML content, to</>Translate special characters to&lt;/&gt;etc., to prevent cross-site scripting (XSS) attacks.escapeandeThe filter is the tool that explicitly performs this escaping operation.
    • safeFilter:On the contrary, when it is determined that a certain segment of HTML content is safe and needs to be rendered as is (for example, the content output by a rich text editor), you can usesafeA filter that tells the system not to escape this content.
    • escapejsFilter:For special characters in JavaScript code,escapejsThe filter can be escaped to ensure that JavaScript code embedded in HTML does not cause parsing errors or security issues.
  3. Correction and formatting of string content.

    • replaceFilter:Before rendering content, you can replace an old keyword with a new one. This can be used to handle irregular text or links in the collected content.
    • cutFilter:Can remove specified characters from any position in a string, which is very effective for clearing specific interfering characters or symbols from collected content.
    • addslashesFilter:Add a backslash before predefined special characters (single quotes, double quotes, backslashes), which is suitable for cleaning up strings that need to be output as JavaScript or SQL parameters.

With these built-in purification tools, Anqi CMS provides users with multi-level, multi-dimensional content processing capabilities, ensuring the neatness, safety, and efficiency of website content, whether it is automated optimization at the stage of content collection and storage, or fine control during the front-end display of content.


Frequently Asked Questions (FAQ)

  1. These cleaning functions are executed before or after the content is stored?The purification function of AnQi CMS is divided into two stages. Image localization, WebP conversion, image compression, external link filtering, and sensitive word filtering are mainly performed before or when the content is collected or imported into the database to ensure the quality of the stored content. Andstriptags/removetags/escapeThe filter is executed when the content is retrieved from the database and rendered to the web page template, used to control the final front-end display effect.

  2. If the content I collect contains malicious HTML code (such as XSS), can AnQiCMS automatically clear it?Yes, AnQiCMS provides protection at multiple levels. Firstly, the sensitive word filtering in content security management can handle known malicious script keywords.Secondly, the default template output mechanism will automatically escape HTML tags, which can effectively prevent most XSS attacks.Only when the user explicitly usessafeA filter and content that itself contains malicious scripts may pose a risk, therefore, vigilance over the source security of collected content must still be maintained.

  3. Can I customize these purification rules, for example, to perform more complex filtering for specific tags or attributes?Can. After the content is stored, you can use the "Full Site Content Replacement" and "Article Content Batch Replacement" features to combine regular expressions to achieve highly customized text and HTML content replacement or deletion.On the front-end display level, by modifying the template file, you can flexibly combine and usestriptags/removetags/replaceFilterers, fine-tune HTML tags and string processing according to specific requirements.

Related articles

How to use AnQiCMS filter to preliminarily sanitize the HTML content uploaded by users?

In website operation, the security and display effect of user uploaded content are crucial.Especially when users have the opportunity to submit content containing HTML tags, how to effectively perform preliminary purification, prevent malicious code injection (XSS attacks), and ensure that the content is presented as expected, is a challenge that each operator needs to face.AnQiCMS as a system focused on efficiency and security, provides us with a variety of tools to meet this need.

2025-11-08

How should I make AnQiCMS display the Markdown original text instead of rendering it as HTML?

In the daily content operation of AnQiCMS, we usually hope that the system can automatically render Markdown content into beautiful HTML for direct display on the website. However, in certain specific scenarios, such as when you may need to export the Markdown original text to other platforms, or display Markdown code blocks directly on the page (such as in tutorials or technical articles), or provide pure Markdown data for API interfaces

2025-11-08

How to ensure proper closing of tags when truncating HTML with the `truncatechars_html` filter?

In website content operation, we often need to truncate the long article content displayed on list pages, abstracts, or card views to maintain the cleanliness and consistency of the page.However, when this content contains HTML tags (such as paragraphs `<p>`, links `<a>`, bold `<strong>`, images `<img>`, etc.), simple string truncation often leads to problems: it may truncate the tags in the middle, causing the page to display incorrectly, and even destroying the entire page's HTML structure.

2025-11-08

Can AnQiCMS's 'Full Site Content Replacement' feature be used to replace HTML code snippets?

AnQiCMS (AnQiCMS) provides strong support for many website operators with its efficient and flexible content management features.Among them, the "All-Station Content Replacement" feature plays an important role in daily operations with its one-click batch processing capability.Whether this feature can be ingeniously applied to replace HTML code snippets in web pages?Let's delve deeper into it.The 'Full Site Content Replacement' feature of Anqi CMS was originally designed to help users quickly and batch modify keywords or links on the website.

2025-11-08

How to remove HTML tags in AnQiCMS template based on conditions?

In the development and maintenance of website templates, we often encounter such needs: to determine whether a certain HTML element is displayed on the page based on specific data conditions.For example, an article only displays the image tag when there is a thumbnail or when a custom field has content, and renders the corresponding block.This "on-demand display" mechanism not only makes the template code cleaner, avoids the appearance of empty tags or unnecessary visual elements on the page, but also significantly improves user experience and page loading efficiency.

2025-11-08

Does AnQiCMS provide a feature to batch remove all HTML tags from all articles under a specific content model?

In website content operation, we often encounter situations where we need to uniformly process a large number of articles, such as for content standardization, SEO optimization needs, or preparing to export content to other platforms, we need to remove the HTML tags from the articles.AnQiCMS (AnQiCMS) is a powerful content management system that provides an efficient way to solve such problems.The Anqi CMS indeed has the ability to remove all HTML tags from all articles under the specified content model in bulk.

2025-11-08

How to convert Markdown to HTML in a template and then remove the tags from the generated HTML?

In the AnQiCMS template, when handling Markdown content, it is often necessary to first convert it to HTML, and then further filter or remove specific HTML tags on this basis.This is particularly useful when creating content summaries, generating plain text previews, or implementing specific layout controls.The template tags and filters provided by AnQi CMS can help us complete these operations efficiently and flexibly.

2025-11-08

Can the `striptags` filter retain images or links in HTML content, while removing only the formatting tags?

In website content operation, we often need to handle text content that contains HTML tags.Sometimes it needs to be converted to plain text, and sometimes it is desired to retain some key elements while removing redundant formats, such as images and links.AnQiCMS's template engine provides a rich set of filters to help us handle such needs, among which the `striptags` filter is a commonly used one.Then, can this `striptags` filter retain images or links in the content when removing HTML tags?in short

2025-11-08