javascript - Unsafe situation occurs when using angular to dynamically assign the src attribute to an image
PHP中文网
PHP中文网 2017-06-05 11:10:10
0
1
1133
  • After Baidu, I set the value of app.config in appmodule $compileProvider.imgSrcSanitizationWhitelist(/^s*(https?|local|data):/);
    But it had no effect

I would like to ask if there are any other ways to remove this unsafe

html code: <p class="user_pic"><img src="{{item.UserID | imgSrc}}" width="100%;" height="178px;"></ p>
In controller: app.filter('imgSrc', function () {

    return function (input) {
        var src = '';
        if (input == undefined) {
            return;
        }
        $.ajax({
            url: BaseURL + "/MainUser/LoadUserPersonalHomepageByUseriD?userID=" + input,
            type: 'get',
            async: false,
            success: function (data) {
                if (data.UploadIMG == null) {
                    src = '/img/tp.png'
                } else {
                    src = data.UploadIMG
                }
            }
        })
        return src;
    }
});
PHP中文网
PHP中文网

认证0级讲师

reply all(1)
習慣沉默

https://stackoverflow.com/que...

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template