Files
php-doc-ru/reference/exec/functions/escapeshellcmd.xml
Alexey Pyltsyn d3bae56d2b Program execution Functions: impovements
git-svn-id: https://svn.php.net/repository/phpdoc/ru/trunk@344292 c90b9560-bf6c-de11-be94-00142212c4b1
2018-02-19 10:48:03 +00:00

150 lines
5.1 KiB
XML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?xml version="1.0" encoding="utf-8"?>
<!-- EN-Revision: d355f93c42aec309f412b317c1e15b088b3fda79 Maintainer: mch Status: ready -->
<!-- Reviewed: yes Maintainer: lex -->
<!-- $Revision$ -->
<!-- splitted from ./en/functions/exec.xml, last change in rev 1.2 -->
<refentry xml:id="function.escapeshellcmd" xmlns="http://docbook.org/ns/docbook">
<refnamediv>
<refname>escapeshellcmd</refname>
<refpurpose>Экранировать метасимволы командной строки</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type>string</type><methodname>escapeshellcmd</methodname>
<methodparam><type>string</type><parameter>command</parameter></methodparam>
</methodsynopsis>
<para>
Команда <function>escapeshellcmd</function> экранирует любые символы в
строке, которые могут быть использованы для обмана команды оболочки при выполнении
произвольных команд. Эта функция должна быть использована, чтобы убедиться,
что любые данные, вводимые пользователем, будут экранированы перед передачей их
функциям <function>exec</function> или
<function>system</function> или оператору <link
linkend="language.operators.execution">"обратный апостроф"</link>.
</para>
<para>
Следующие символы будут экранированы при помощи обратного слеша:
<literal>&amp;#;`|*?~&lt;&gt;^()[]{}$\</literal>, <literal>\x0A</literal>
и <literal>\xFF</literal>. Символы <literal>'</literal> и <literal>"</literal>
экранируются только в том случае, если они встречаются не попарно. В Windows все
эти символы, плюс <literal>!</literal> и <literal>%</literal> заменяются пробелом.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>command</parameter></term>
<listitem>
<para>
Команда, которая будет экранирована.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
Экранированная строка.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>Пример использования <function>escapeshellcmd</function></title>
<programlisting role="php">
<![CDATA[
<?php
// Мы намеренно допускаем здесь произвольное количество аргументов.
$command = './configure '.$_POST['configure_options'];
$escaped_command = escapeshellcmd($command);
system($escaped_command);
?>
]]>
</programlisting>
</example>
</para>
</refsect1>
<refsect1 role="notes">
<warning xmlns="http://docbook.org/ns/docbook">
<para>
Функцию <function>escapeshellcmd</function> следует использовать над всей
командной строкой, но она все еще позволяет атакующему передать
произвольное количество аргументов. Для экранирования одного аргумента
вместо нее необходимо использовать функцию <function>escapeshellarg</function>.
</para>
</warning>
</refsect1>
<refsect1 role="changelog">
&reftitle.changelog;
<para>
<informaltable>
<tgroup cols="2">
<thead>
<row>
<entry>&Version;</entry>
<entry>&Description;</entry>
</row>
</thead>
<tbody>
&strings.changelog.encoding;
<row>
<entry>5.4.43, 5.5.27, 5.6.11</entry>
<entry>
Восклицательные знаки заменяются пробелами.
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</para>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>
<simplelist>
<member><function>escapeshellarg</function></member>
<member><function>exec</function></member>
<member><function>popen</function></member>
<member><function>system</function></member>
<member><link linkend="language.operators.execution">Оператор исполнения</link></member>
</simplelist>
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->