{"id":126126,"date":"2020-01-15T22:05:01","date_gmt":"2020-01-15T14:05:01","guid":{"rendered":"http:\/\/4563.org\/?p=126126"},"modified":"2020-01-15T22:05:01","modified_gmt":"2020-01-15T14:05:01","slug":"%e5%a6%82%e4%b8%8b%e8%bf%99%e4%b8%aa%e6%9b%bf%e6%8d%a2%e6%ad%a3%e5%88%99%e8%af%a5%e6%80%8e%e4%b9%88%e5%86%99%ef%bc%9f","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=126126","title":{"rendered":"\u5982\u4e0b\u8fd9\u4e2a\u66ff\u6362\u6b63\u5219\u8be5\u600e\u4e48\u5199\uff1f"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  \u5982\u4e0b\u8fd9\u4e2a\u66ff\u6362\u6b63\u5219\u8be5\u600e\u4e48\u5199\uff1f               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : getlost <\/span>  <span><i><\/i> 84<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<pre><code>{% static &amp;#39;image\/27119724.jpg&amp;#39; %} <\/code><\/pre>\n<p>\u7528 JavaScript\uff0c\u66ff\u6362\u6210<\/p>\n<pre><code>{% static 'image\/27119724.jpg' %} <\/code><\/pre>\n<p>\u6211\u8bd5\u8fc7\u7528<\/p>\n<pre><code>str.replace(\/&amp;#[0-9]*;\/g, \"'\") <\/code><\/pre>\n<p>\u4f46\u662f\u6ca1\u6210\u529f\uff0c\u4e0d\u77e5\u9053\u9519\u5728\u90a3\u4e86<\/p>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>7<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"63305\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : ClericPy <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u8fd9\u79cd HTML \u5b9e\u4f53\u7b26\u76f4\u63a5 unescape \u4e00\u6b21\u4e0d\u5c31\u51fa\u6765\u4e86&#8230; \u800c\u4e14\u4e5f\u4e0d\u8be5\u662f [0-9], \u6709\u7684\u5b9e\u4f53\u7b26\u4e0d\u662f\u5f15\u53f7<\/p>\n<p>\u56de\u5230\u6b63\u5219<\/p>\n<p>\u4f60\u7684\u8868\u8fbe\u5f0f\u662f\u6b63\u786e\u7684, \u7528 console.log \u53ef\u4ee5\u770b\u5230, \u6240\u4ee5\u76ee\u6d4b\u662f\u4f60\u7528\u4e86\u4e2a\u4ec0\u4e48\u540e\u7aef\u6846\u67b6, \u7136\u540e\u5728\u6a21\u677f\u91cc\u4e22\u4e86\u4e2a\u5b57\u7b26\u4e32, \u4f46\u662f\u5bf9 unsafe \u7684\u5b57\u7b26\u4e32, \u4f1a\u88ab\u8f6c\u4e49, \u6240\u4ee5\u4f60\u8be5\u505a\u7684\u5e94\u8be5\u662f\u8df3\u8fc7\u8f6c\u4e49                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"63306\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : Mikewu <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             &#8220;`javascript<br \/>let str = &#8216;{% static &amp;#39;image\/27119724.jpg&amp;#39; %}&#8217;<br \/>str = str.replace(\/&amp;#[0-9]*;\/g, &#8220;&#8216;&#8221;)<br \/>console.log(&#8216;str: &#8216;, str)<br \/>&#8220;`                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"63307\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : getlost <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @ClericPy \u672c\u6765\u662f\u5b66\u4e60 Django \u7684\uff0c\u4f46\u662f\u8fd8\u6ca1\u5b66\u4f1a\u524d\u540e\u53f0\u6570\u636e\u4f20\u9001\uff0c\u6240\u4ee5\u60f3\u7740\u628a\u56fe\u7247\u5730\u5740\u6570\u636e\u4e22\u5728\u6a21\u677f\u91cc\uff0c\u7136\u540e\u66ff\u6362\u4e00\u4e0b\uff0c\u628a\u56fe\u7247\u52a0\u8f7d\u51fa\u6765\uff0c\u7ed3\u679c\u5361\u5728\u8fd9\u4e86\uff0c\u7136\u540e\u8f6c\u53bb\u770b JavaScript \u7684\u5185\u5bb9\uff0c\u60f3\u7740\u5148\u5f04\u51fa\u6765\u518d\u641e\u4e0b\u4e00\u6b65\uff0c\u6ca1\u60f3\u5230\u8fd9\u4e2a\u95ee\u9898\u597d\u51e0\u5929\u90fd\u6ca1\u89e3\u51b3\u3002<br \/>\u6211\u611f\u89c9\u8fd9\u4e2a\u6b63\u5219\u6ca1\u5bf9\uff0c\u56e0\u4e3a\u6211\u8bd5\u8fc7 str.replace(\/&amp;#[0-9]*;\/g, &#8220;gg&#8221;) \u7136\u540e console.log \uff0c\u7ed3\u679c\u6ca1\u6709\u66ff\u6362\u3002\u6211\u53bb\u67e5\u67e5\u4f60\u8bf4\u7684\u8df3\u8fc7\u8f6c\u4e49\uff0c\u8c22\u8c22\u554a                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"63308\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : getlost <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @Mikewu \u5927\u5144\u5f1f\uff0c\u6211\u5c31\u662f\u8fd9\u6837\u5199\u7684\uff0c\u4f46\u662f\u6ca1\u66ff\u6362                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"63309\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : Mikewu <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @getlost #3 replace \u65b9\u6cd5\u662f\u8fd4\u56de\u4e00\u4e2a\u65b0\u7684\u5b57\u7b26\u4e32\uff0c\u800c\u4e0d\u662f\u4fee\u6539\u539f\u6765\u7684 str                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"63310\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : ClericPy <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @getlost #3 \u6211\u4ee5\u524d\u7528 flask \u7684 jinja2 \u6a21\u7248, {{ var_name | safe }} \u8fd9\u6837\u7ba1\u9053\u7b26 safe \u6765\u907f\u514d\u8f6c\u4e49\u7684, \u4e0d\u8fc7\u5927\u90e8\u5206\u5730\u65b9\u90fd\u4e0d\u5efa\u8bae\u7528<\/p>\n<p>\u968f\u624b\u641c\u4e86\u4e0b, Django \u4e5f\u662f, google \u641c\u7d22\u5173\u952e\u8bcd Django template safe<\/p>\n<p>https:\/\/stackoverflow.com\/questions\/4056883\/when-should-i-use-escape-and-safe-in-djangos-template-system<\/p>\n<p>\u867d\u7136\u6211\u7528\u7684 doge \u641c\u7d22                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"63311\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : netnr <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             &#8216;{% static &amp;#39;image\/27119724.jpg&amp;#39; %}&#8217;.replace(\/&amp;#[0-9]{2};\/g,&#8221;)                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>\u5982\u4e0b\u8fd9\u4e2a\u66ff\u6362\u6b63\u5219\u8be5\u600e\u4e48\u5199\uff1f \u8cc7\u6df1\u5927&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/126126"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=126126"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/126126\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=126126"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=126126"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=126126"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}