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.