Make WordPress Core

Changes between Version 2 and Version 3 of Ticket #43438, comment 44


Ignore:
Timestamp:
05/01/2018 12:31:26 PM (8 years ago)
Author:
birgire
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #43438, comment 44

    v2 v3  
    1 An additional important thing here is that we need to sanitize the exporter/eraser friendly name.
     1An additional important thing here is that we need to sanitize/escape the exporter/eraser friendly name.
    22
    33We don't want it to contain HTML and stuff, but currently it goes through.
     
    1919The {{{wp_send_json_error()}}} is a wrapper for {{{wp_send_json()}}} that uses {{{wp_encode_json()}}}.
    2020
    21 What comes to mind are {{{esc_js()}}} and {{{wp_encode_json()}}}, but I'm thinking {{{sanitize_text_field()}}} on {{{$exporter['exporter_friendly_name']}}} should do it here.
     21What comes to mind are {{{esc_js()}}}, {{{esc_html()}}} and {{{wp_encode_json()}}} but I'm thinking {{{sanitize_text_field()}}} on {{{$exporter['exporter_friendly_name']}}} should do it here.
     22
    2223
    2324What do you think?
    2425
     26ps: I did some testing here:
    2527
     28
     29{{{
     30Raw friendly name:
     31WordPress Comments " \' \ - &amp; & <b>Hello</b> <script>alert(1)</script>
     32
     33sanitize_text_field:
     34<li>Exporter does not include a callback: WordPress Comments " ' \ - &amp; &amp; Hello.</li>
     35
     36esc_html:
     37<li>Exporter does not include a callback: WordPress Comments " ' \ - &amp; &amp; &lt;b&gt;Hello&lt;/b&gt; &lt;script&gt;alert(1)&lt;/script&gt;.</li>
     38
     39esc_js:
     40<li>Exporter does not include a callback: WordPress Comments " \'  - &amp; &amp; &lt;b&gt;Hello&lt;/b&gt; &lt;script&gt;alert(1)&lt;/script&gt;.</li>
     41
     42esc_html + sanitize_text_field:
     43<li>Exporter does not include a callback: WordPress Comments " ' \ - &amp; &amp; Hello.</li>
     44
     45esc_js + sanitize_text_field:
     46<li>Exporter does not include a callback: WordPress Comments " \'  - &amp; &amp; Hello.</li>
     47
     48wp_json_encode:
     49<li>Exporter does not include a callback: "WordPress Comments \" ' \\ - &amp; &amp; <b>Hello&lt;\/b&gt; <script>alert(1)<\/script>".</li></ul></div></td></tr></tbody></table></script></b></li>
     50
     51}}}