admin管理员组文章数量:1313736
I'm looking to sanitize admin form input for update_option. The input is for a directory path and file name. The input will look like this:
/directory/subdirectory/
and
/thisfile.min.js
So far, every sanitize I've tried strips out the forward slashes. Any suggestions?
I'm looking to sanitize admin form input for update_option. The input is for a directory path and file name. The input will look like this:
/directory/subdirectory/
and
/thisfile.min.js
So far, every sanitize I've tried strips out the forward slashes. Any suggestions?
Share Improve this question asked Nov 27, 2020 at 15:11 uPromptuPrompt 1729 bronze badges1 Answer
Reset to default 1The function that you would want to use is sanitize_text_field()
which among other things, strips all HTML tags, and remove line breaks, tabs and extra white space.
// This worked fine for me - I got /directory/subdirectory/
$value = sanitize_text_field( '/directory/subdirectory/' );
// And so does this one - I got /thisfile.min.js
$value = sanitize_text_field( '/thisfile.min.js' );
// Even with an actual form input (e.g. <input name="my_field">),
// the function worked just fine (using the same data as above).
$value = sanitize_text_field( $_POST['my_field'] );
So have you already tried that function and are you sure it stripped the /
? How about the other similar functions listed here?
本文标签: pluginsSanitizing file amp directory form input
版权声明:本文标题:plugins - Sanitizing file & directory form input 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741958743a2407142.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论