小编mis*_*olf的帖子

由hasPasswordField_引发的Facebook iFrame安全错误(document.domain)

我们有一个使用标准Facebook API的项目,主要用于登录和注册.由于我们使用Sentry接收错误通知,因此通常会出现以下内容(在主页中):

SecurityError: Blocked a frame with origin "https://www.mywebsite.com" from accessing a 
frame with origin "https://www.facebook.com". The frame being 
accessed set "document.domain" to "facebook.com", but the frame requesting access did not. 
Both must set "document.domain" to the same value to allow access.
at hasPasswordField_ (/en:1:368)
at hasPasswordField_ (/en:1:499)
at findPasswordForms (/en:1:173)
at global code (/en:10:27)
Run Code Online (Sandbox Code Playgroud)

这很奇怪,因为这些方法

 hasPasswordField_ / findPasswordForms
Run Code Online (Sandbox Code Playgroud)

在项目代码上不存在.

因为错误目前只发生在

iOS Chrome Mobile,版本:59.0.3071 | 60.0.3112

有一个Chrome内部组件正在尝试访问Facebook iFrame,或者是Facebook在网页上搜索某些密码字段?

更新: 进一步搜索后,我在Sentry GIT页面上发现了这篇文章:https: //github.com/getsentry/sentry/issues/5267 他们建议只是忽略错误.

任何想法如何面对它不同?任何帮助将不胜感激!

javascript iframe facebook google-chrome ios

6
推荐指数
1
解决办法
613
查看次数

鼠标右键单击Firefox会触发单击事件

我注意到,在Firefox上单击鼠标右键会触发addEventListener。

我在更多浏览器和更多操作系统(IE 11-10-9,Safari,Chrome)上尝试了此代码,并通过右键单击鼠标,仅在Firefox上始终打印console.log消息。

<div id="one-div" style="height:400px;width:500px;background-color:#000;"> click me </div>
<script>
    function cb(event, from){
        // if click is fired on <div> with:
        // left click, both EventListener will be printed.
        // right click, only the 'document' one will be printed.
        event.preventDefault();
        console.log(event + ' from: ' + from );
    }
    document.addEventListener('click', function(e){
        cb(e,'document');
    }, false);
    document.getElementById("one-div").addEventListener('click', function(e){
        cb(e,'one-div');
    }, false);
</script>
Run Code Online (Sandbox Code Playgroud)

而且我还注意到,当将点击触发到div中时,它仅触发document.addEventListener。我搜索了Firefox changelog,但没有相关新闻。

谁能解释这种行为?谢谢!

javascript mouse firefox right-click

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

正则表达式组重复字母

我试图将所有重复的字母分组成一个字符串.

例如:

"aaaaaaabbbbbbbbc" => [['aaaaaaa'],['bbbbbbbb'],['c']]
Run Code Online (Sandbox Code Playgroud)

使用逻辑和Ruby,我能找到达到我意图的唯一方法是:

.scan(/(?:a+|A+)|(?:b+|B+)|(?:c+|C+)| ..... (?:y+|Y+)|(?:z+|Z+))
Run Code Online (Sandbox Code Playgroud)

...其他字母在哪里.

还有办法让RegEx干掉吗?我也使用了backtrace (\1),但它与单个单词不匹配,并且它不会返回完全匹配的字母match => (\w+)\1=>[['aa'],['bb']]

嗯,我在这种情况下使用正则表达式是错误的,我应该在迭代中使用Ruby方法吗?

我很高兴听到你的意见:)谢谢!

ruby regex repeat

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