[WordPress] 外掛分享: Secure Gettext

首頁外掛目錄 › Secure Gettext
全新外掛
安裝啟用
★★★★★
5/5 分(1 則評價)
3726 天前
最後更新
問題解決
WordPress 2.0.11+ v0.1 上架:2016-01-05

內容簡介

該外掛確保來自翻譯文件(.po或.mo)的任何文本在輸出到用戶之前都會經過一個轉義函數處理。

轉義是指修改文本,使得特殊的控制字符不會產生影響(例如 HTML 中的<)。

例如,如果原始文本不包含 HTML,那麼翻譯後的文本也不應該包含 HTML。因此,翻譯人員添加的 HTML 鏈接不應該產生任何影響,因為開發人員本意不是這樣。

該外掛目前處於概念驗證階段,旨在測試是否可以通過通用方式處理轉義翻譯文本,以及它是否會嚴重影響網站的性能以及是否會導致問題。

對於不包含 HTML 的文本,將文本通過esc_html()進行處理,對於包含 HTML 標籤的文本,則通過wp_kses()進行處理,該函數提供了一個允許使用的 HTML 標籤和屬性列表,從原始字符串中推導而來。

因此,該外掛試圖展示如何確保翻譯文本得到轉義的通用方式。這是最終可以移植到 WordPress 核心的功能。

外掛標籤

開發者團隊

⬇ 下載最新版 (v0.1) 或搜尋安裝

① 下載 ZIP → 後台「外掛 › 安裝外掛 › 上傳外掛」
② 後台搜尋「Secure Gettext」→ 直接安裝(推薦)

原文外掛簡介

This plugin ensures that any text coming from a translation file (.po or .mo) is run through an escaping function before it is output to the user.
Escaping refers to the modification of the text so that special control characters do not have an effect (for example < in HTML). Example: If an original text does not contain HTML, then a translated text should not be allowed to contain HTML either. Thus, an HTML link introduced by a translator should have no effect because this was not intended by the developer. This plugin is in the proof-of-concept stage, it was created to test if the escaping of translated text can be handled in a general way, whether it severely affects the performance of a site, and if it breaks things. For text without HTML, the text is sent through esc_html(), for text containing HTML tags, it is sent through wp_kses() which is provided with a list of allowed HTML tags and attributes, derived from the original string. Thus this plugin tries to show a generic way of how to make sure that translated text is escaped. This is something that can eventually be ported to core.

延伸相關外掛

文章
Filter
Mastodon