Drupal / CKEditor和输入过滤,如何返回干净的值?

发布于 2024-09-24 15:41:33 字数 374 浏览 9 评论 0原文

我有一个使用 CKEditor 和 CCK 设置的 Drupal,其中有一个自定义节点,其中有一些使用 CKEditor 的附加字段,其中一个字段是“lated_news”。

我正在尝试找出安全返回数据的最佳实践。我现在所拥有的是:

$node = noad_load(35);
<h3>Related News</h3>
<?php print $node->field_related_news['0']['value']; ?>

但这会返回潜在危险的数据,因为没有对其使用过滤。

我已进入“输入设置”并启用“过滤 HTML”,但仍然遇到此问题。

有什么想法吗?最佳实践?

I have a Drupal set up with CKEditor and CCK, with a custom node which has some additional fields using CKEditor, one field being 'related_news'.

I'm trying to figure out the best practice for returning that data safely. What I have right now is:

$node = noad_load(35);
<h3>Related News</h3>
<?php print $node->field_related_news['0']['value']; ?>

But that returns potentially dangerous data, since no filtering is being used on it.

I've gone to my Input Settings and enabled Filtered HTML and I'm still getting this issue.

Any ideas? Best practices?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

乖不如嘢 2024-10-01 15:41:33

首先,当您创建 CCK 字段时,有一个设置(在“全局设置”下)

Text processing:
[ ] Plain text
[x] Filtered text (user selects input format)

我希望您选择“过滤文本”设置。只有这样,才会对该字段进行输入过滤。

过滤后的字符串应以

$node->field_lated_news['0']['safe']形式提供

First of all, when you create the CCK field, there is a setting (under Global Settings)

Text processing:
[ ] Plain text
[x] Filtered text (user selects input format)

I hope you selected that the Filtered text setting. Only then it is input filtering done for that field.

The filtered string should be available as

$node->field_related_news['0']['safe']

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文