小编chr*_*con的帖子

如何保护加载数据本地 infile 更新查询免受 SQL 注入

在我的应用程序中,我需要提供上传 csv 和 excel 文件的可能性,然后将这些文件用于更新数据库。这些文件包含+/-几百万行,所以我需要使用加载本地数据infile:

$stmt1 = $dbh->prepare("CREATE TEMPORARY TABLE ${prefix}tempskuEAN LIKE ${prefix}skuEAN");

$stmt4 = $dbh->prepare("LOAD DATA LOCAL INFILE '/ama/$aa[0]/CustomerUpload/$a.csv' INTO TABLE ${prefix}tempskuEAN FIELDS TERMINATED BY ';' OPTIONALLY ENCLOSED BY '\"' (seller_sku, EAN, fallback)");

$stmt5 = $dbh->prepare("UPDATE ${prefix}skuEAN a LEFT JOIN ${prefix}tempskuEAN b ON a.seller_sku = b.seller_sku SET a.EAN = b.EAN, a.fallback = b.fallback WHERE a.seller_sku = b.seller_sku");

$stmt6 = $dbh->prepare("DROP TEMPORARY TABLE ${prefix}tempskuEAN");
Run Code Online (Sandbox Code Playgroud)

$stmt4 中的变量是由我的程序设置的,因此它们不会成为问题,但我非常担心更新/插入值的安全性。有没有什么方法可以在不损失性能的情况下将这些值与加载数据本地文件一起转义?

mysql security pdo sql-injection load-data-infile

3
推荐指数
1
解决办法
2207
查看次数

React 样式 prop 为数组返回 [object object]?

我有这个非常基本的组件:

Tile = React.createClass({
    render: function(){
        var styles = [
            TileStyles.tile
        ];
        return (
            <div style={styles} test="test" />
        );
    }
});
Run Code Online (Sandbox Code Playgroud)

不幸的是,它正在生成这个 html:

<div style="0:[object Object];" data-reactid=".0.$0"></div>
Run Code Online (Sandbox Code Playgroud)

为什么它给我 [object object] 而不是内联样式?显然我不需要在这里使用数组,但我在更复杂的组件上使用。

我究竟做错了什么?

更新:感谢大家的回答,但问题是我希望能够使用多种样式。

也就是在某些情况下使用 TileStyles.tile 和 TileStyles.active。

javascript inline-styles reactjs

3
推荐指数
1
解决办法
8936
查看次数

春云流兔的退避设置

我仍在使用rabbitmq和spring云消息传递设置示例消息传递系统,但遇到了错误(?),或者我误解了文档。(使用spring-boot版本2.0.3.RELEASE)

为了这个例子,我想要以下设置

  spring:
    cloud:
      stream:
        rabbit:
          bindings:
            foo:
              consumer:
                auto-bind-dlq: true
        instanceCount: 2
        instanceIndex: 0
        bindings:
          foo:
            destination: foo
            group: fooGroup
            consumer:
              maxAttempts: 4
              backOffInitialInterval: 10000
              backOffMultiplier: 10.0 
          fooChannel:
            destination: foo
Run Code Online (Sandbox Code Playgroud)

这个问题有趣的部分是spring.cloud.stream.bindings.foo.consumer,我设置了 4 个 maxAttempts,初始退避间隔为 10 秒,乘数为 10。

应用 maxAttempts 和初始间隔,但不应用乘数。根据文档(此处此处),按键采用驼峰式设计,但backOffInitialInterval在应用时似乎也能正常工作back-off-initial-interval。我对按键的所有不同方式感到有点困惑,但那是另一个故事了。

我已经尝试了所有可能的写作方式backOffMultiplier,但它没有得到应用,消息每 10 秒发送一次。

现在,为了测试到底出了什么问题,我@Bean手动设置并配置了 RetryTemplate

@Bean
    RetryTemplate retryTemplate() {
        RetryTemplate r = new RetryTemplate();

        ExponentialBackOffPolicy exponentialBackOffPolicy = new ExponentialBackOffPolicy();
        exponentialBackOffPolicy.setInitialInterval(10000);
        exponentialBackOffPolicy.setMultiplier(10.0);
        exponentialBackOffPolicy.setMaxInterval(100000);
        r.setBackOffPolicy(exponentialBackOffPolicy);

        SimpleRetryPolicy simpleRetryPolicy …
Run Code Online (Sandbox Code Playgroud)

java spring spring-rabbit spring-boot spring-messaging

3
推荐指数
1
解决办法
2663
查看次数

HTML:如何创建搜索栏?

我有这个搜索栏:

<div id="tfheader">
    <form id="tfnewsearch" method="get" action="http://mywebsite.com">
            <input type="text" class="tftextinput" name="q" size="21" maxlength="120"><input type="submit" value="search" class="tfbutton">
    </form>
<div class="tfclear"></div>
</div>
Run Code Online (Sandbox Code Playgroud)

它工作得很好,但是当我搜索“关键字”时,它会重定向到http://mywebsite.com/?q=keyword

如何重定向到http://mywebsite.com/keyword?非常感谢 !

html javascript search

2
推荐指数
1
解决办法
2万
查看次数

如何在 Laravel 5 中全局防止保存到数据库

我在 Laravel 中制作了一个 PHP 脚本,现在我想向我的买家展示演示。由于我不希望他们对数据库进行任何更改,我想知道是否有办法全局禁用对数据库的任何保存?

eloquent laravel-5

2
推荐指数
1
解决办法
1194
查看次数

Javascript/jQuery从字符串中获取前100个字符,尊重完整的单词

我遇到了很多关于此的问题,我找到了仅适用于PHP的解决方案.这个站点上没有jQuery/javascript方法的解决方案.

我想要做的是我想要显示前100个字符,但我不想删掉最后一个字,因为它将毫无意义.

就像说this is myself是最后一个单词所以它我们经常采用子串并且y是第100个单词,然后它会削减它this is my,这意味着更少.所以我想要它this is..

我原来的代码:

jQuery(".block-text .success-inner-content").each(function(){
    if(jQuery(this).text().length > 100){
        jQuery(this).text(jQuery(this).text().substr(0,98)+'..');
    }
});
Run Code Online (Sandbox Code Playgroud)

这里的block-text .success-inner-content类是循环生成Div的列表,其中包含文本.

html javascript regex jquery substring

2
推荐指数
1
解决办法
7155
查看次数

如何将ng-repeat中的最后一项返回给控制器

我想运行一个字符串函数,删除最后一个span元素上的逗号.

<p class="genres">
    <span class="plabel">Genres</span>: 
    <span class="genre_name" ng-repeat="genres in movie.genres"
          ng-class="{'last': $last}">{{genres.name}}, 
    </span>
</p>
Run Code Online (Sandbox Code Playgroud)

angularjs

2
推荐指数
1
解决办法
664
查看次数

Firebase云消息传递requireInteraction不起作用

参考:https://github.com/firebase/quickstart-js/tree/master/messaging

我添加了键值对:

"requireInteraction": true
Run Code Online (Sandbox Code Playgroud)

但桌面Chrome中的通知在20秒后仍然消失.有人知道Firebase是否支持这个键值对吗?谢谢!

我的例子如下.请换[...]到你的.

curl -X POST -H "Authorization: key=[...]" -H "Content-Type: application/json" -d '{
  "notification": {
    "requireInteraction": true,     
    "title": "This is custom title",
    "body": "this is custom body",
    "click_action": "https://google.com",
    "data" : {"requireInteraction": true  }
 },
  "to": "[...]",
}' "https://fcm.googleapis.com/fcm/send"
Run Code Online (Sandbox Code Playgroud)

javascript google-chrome push-notification firebase firebase-cloud-messaging

2
推荐指数
1
解决办法
1274
查看次数

How to wrap multiple HTML strings with tags?

I'm a new to coding and trying to wrap a large list of strings with HTML tags. After searching, I already found a method here but I've tried it in VS Code and it seems to be not working for me. Probably I'm doing something wrong.

To clarify it further, I'm trying to wrap a large list of strings with HTML tags.

Elina Arnwine
Freddie Cane
Melia Pittenger
Nobuko Grove
.....
Run Code Online (Sandbox Code Playgroud)

to

<li class="nav-item"><a href="" class="nav-link text-small pb-0 ">Elina Arnwine</a></li> …
Run Code Online (Sandbox Code Playgroud)

html javascript

2
推荐指数
1
解决办法
42
查看次数

Angular Location.onUrlChange 如何正确取消订阅

Angular 的位置服务有一个方法onUrlChange可以注册 popstate 或 hashchange 没有的 url 事件,我的项目的一部分需要它。

  /**
   * Registers a URL change listener. Use to catch updates performed by the Angular
   * framework that are not detectible through "popstate" or "hashchange" events.
   *
   * @param fn The change handler function, which take a URL and a location history state.
   */
  onUrlChange(fn: (url: string, state: unknown) => void) {
    this._urlChangeListeners.push(fn);
    this.subscribe(v => { this._notifyUrlChangeListeners(v.url, v.state); });
  }
Run Code Online (Sandbox Code Playgroud)

与平常不同的是,不会返回任何订阅,因此我们无法在销毁时取消订阅。在离开需要侦听这些事件的路线后,侦听器仍然完好无损。

目前我的丑陋黑客是过滤Locations private _urlChangeListeners onDestroy,但这依赖于String(fn) !== …

javascript angular

2
推荐指数
1
解决办法
4188
查看次数