<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/taint.detail.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'es',
  ),
  'this' => 
  array (
    0 => 'taint.detail.basic.php',
    1 => 'C&oacute;mo se propaga la marca de corrupci&oacute;n',
    2 => 'C&oacute;mo se propaga la marca de corrupci&oacute;n',
  ),
  'up' => 
  array (
    0 => 'taint.detail.php',
    1 => 'Propagaci&oacute;n y puntos comprobados',
  ),
  'prev' => 
  array (
    0 => 'taint.detail.php',
    1 => 'Propagaci&oacute;n y puntos comprobados',
  ),
  'next' => 
  array (
    0 => 'taint.detail.sinks.php',
    1 => 'D&oacute;nde emite advertencias taint',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'es',
    'path' => 'reference/taint/detail.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="taint.detail.basic" class="section">
  <h2 class="title">Cómo se propaga la marca de corrupción</h2>
  <p class="simpara">
   La marca de corrupción es un único bit almacenado en el propio string, no
   en la variable que lo contiene. Asignar, pasar o compartir de cualquier
   otra forma un string corrompido conserva la marca. La concatenación y la
   interpolación de strings también la propagan:
  </p>
  <p class="para">
   <table class="doctable table">
    <caption><strong>Operadores que propagan la marca de corrupción</strong></caption>
    
     <tbody class="tbody">
      <tr>
       <td><code class="literal">=</code> (asignación, incluyendo <code class="literal">list()</code> y la desestructuración de arrays)</td>
      </tr>

      <tr>
       <td><code class="literal">.</code> (concatenación)</td>
      </tr>

      <tr>
       <td><code class="literal">.=</code> (asignación con concatenación)</td>
      </tr>

      <tr>
       <td><code class="literal">&quot;{$var}&quot;</code> (interpolación de strings, incluyendo la vía rápida <code class="literal">ROPE</code>)</td>
      </tr>

     </tbody>
    
   </table>

  </p>
  <p class="simpara">
   Además, taint conoce un conjunto fijo de funciones de strings: cuando
   alguno de los argumentos de tipo string relevantes está corrompido, el
   string devuelto también se marca como corrompido. Se cubren tanto la
   llamada habitual como, en PHP 8.4 y posteriores, la llamada por la vía
   rápida sin marco de pila.
  </p>
  <p class="para">
   <table class="doctable table">
    <caption><strong>Funciones que propagan la marca de corrupción</strong></caption>
    
     <tbody class="tbody">
      <tr>
       <td><span class="function"><a href="function.trim.php" class="function">trim()</a></span>, <span class="function"><a href="function.rtrim.php" class="function">rtrim()</a></span>, <span class="function"><a href="function.ltrim.php" class="function">ltrim()</a></span></td>
      </tr>

      <tr>
       <td><span class="function"><a href="function.substr.php" class="function">substr()</a></span>, <span class="function"><a href="function.strstr.php" class="function">strstr()</a></span></td>
      </tr>

      <tr>
       <td><span class="function"><a href="function.str-replace.php" class="function">str_replace()</a></span>, <span class="function"><a href="function.str-ireplace.php" class="function">str_ireplace()</a></span></td>
      </tr>

      <tr>
       <td><span class="function"><a href="function.str-pad.php" class="function">str_pad()</a></span>, <span class="function"><a href="function.strtolower.php" class="function">strtolower()</a></span>, <span class="function"><a href="function.strtoupper.php" class="function">strtoupper()</a></span>, <span class="function"><a href="function.strval.php" class="function">strval()</a></span></td>
      </tr>

      <tr>
       <td><span class="function"><a href="function.explode.php" class="function">explode()</a></span> (cada elemento del array resultante)</td>
      </tr>

      <tr>
       <td><span class="function"><a href="function.implode.php" class="function">implode()</a></span>/<span class="function"><a href="function.join.php" class="function">join()</a></span> (un separador corrompido también corrompe el resultado)</td>
      </tr>

      <tr>
       <td><span class="function"><a href="function.sprintf.php" class="function">sprintf()</a></span>, <span class="function"><a href="function.vsprintf.php" class="function">vsprintf()</a></span> (solo el especificador <code class="literal">%s</code> transporta la marca; <code class="literal">sprintf(&quot;%d&quot;, $t)</code> devuelve un string limpio)</td>
      </tr>

      <tr>
       <td><span class="function"><a href="function.dirname.php" class="function">dirname()</a></span>, <span class="function"><a href="function.basename.php" class="function">basename()</a></span>, <span class="function"><a href="function.pathinfo.php" class="function">pathinfo()</a></span></td>
      </tr>

     </tbody>
    
   </table>

  </p>
  <p class="simpara">
   Cualquier función que taint no conozca explícitamente devuelve un string
   nuevo y sin marcar, incluidas las funciones de escapado como
   <span class="function"><a href="function.htmlspecialchars.php" class="function">htmlspecialchars()</a></span>, <span class="function"><a href="function.htmlentities.php" class="function">htmlentities()</a></span> o
   <span class="function"><a href="mysqli.real-escape-string.php" class="function">mysqli_real_escape_string()</a></span>. Esto es deliberado: taint
   informa de más de la cuenta en lugar de intentar decidir si un valor es
   <q class="quote">seguro</q> para un contexto de salida concreto. Se debe usar
   <span class="function"><a href="function.untaint.php" class="function">untaint()</a></span> para eliminar la marca de los valores que se
   hayan validado manualmente.
  </p>
 </div><?php manual_footer($setup); ?>