Prechádzať zdrojové kódy

Fix CVE-2022-0323 (improper neutralization of section names)

- Fixes possible RCE when rendering untrusted user templates.
- Remove unnecessary comments in generated source.
Justin Hileman 3 rokov pred
rodič
commit
579ffa5c96
1 zmenil súbory, kde vykonal 2 pridanie a 4 odobranie
  1. 2 4
      src/Mustache/Compiler.php

+ 2 - 4
src/Mustache/Compiler.php

@@ -320,7 +320,6 @@ class Mustache_Compiler
     }
 
     const SECTION_CALL = '
-        // %s section
         $value = $context->%s(%s);%s
         $buffer .= $this->section%s($context, $indent, $value);
     ';
@@ -391,11 +390,10 @@ class Mustache_Compiler
         $id      = var_export($id, true);
         $filters = $this->getFilters($filters, $level);
 
-        return sprintf($this->prepare(self::SECTION_CALL, $level), $id, $method, $id, $filters, $key);
+        return sprintf($this->prepare(self::SECTION_CALL, $level), $method, $id, $filters, $key);
     }
 
     const INVERTED_SECTION = '
-        // %s inverted section
         $value = $context->%s(%s);%s
         if (empty($value)) {
             %s
@@ -418,7 +416,7 @@ class Mustache_Compiler
         $id      = var_export($id, true);
         $filters = $this->getFilters($filters, $level);
 
-        return sprintf($this->prepare(self::INVERTED_SECTION, $level), $id, $method, $id, $filters, $this->walk($nodes, $level));
+        return sprintf($this->prepare(self::INVERTED_SECTION, $level), $method, $id, $filters, $this->walk($nodes, $level));
     }
 
     const PARTIAL_INDENT = ', $indent . %s';