正如您将在图像中看到的那样,有许多红点显然每个都标识为 \u0
文件内容或编辑器没有区别。
编译或未编译的 JS 文件没有区别,事实上,由于空格和换行,在非压缩版本中出现更多红点,即使是加载空白文件然后添加简单的内容,如 console.log('abc ') 将只产生所有红点;
添加内容
这些不可见和不可选择的字符在文件末尾出现的次数与我在脚本的任何其他部分键入的任何其他字符的次数相同。
The invisible characters are not in the actual file itself on disk only in the one served by the web server.
删除内容
如果我启动 VM,然后从 JS 脚本中的任何位置删除字符,那么相同数量的字符将从文件的 webresponse 请求中的内容末尾消失。
未经修改的使用
当我第一次启动 VM 并在浏览器中访问网站时,只要文件从未以任何方式被修改,多次请求就不会出现错误。
结论
如果我在 VM 运行时以任何方式修改文件,结果就好像服务器以某种方式保留了服务器首次启动或首次提供内容时文件字节大小的快照。然后在服务器运行时对文件内容进行更改时,如果文件变小,它会切断内容,或者如果变大,则用\u0 填充,就像它正在填充文件一样。
可以清除不是永久性的故障
如果我在文件损坏后重新启动 VM,并使用之前导致错误的修改刷新对 js 文件的请求,则错误消失,我的新更改没问题。
我还可以撤消破坏响应的最后更改,然后继续正常操作。
This issue only just started happening since the 18th November give or take a couple of days and I had been running the setup for over a month prior without issue, the only thing I remember changing recently is a couple of windows updates last week?
我在 Windows 10 上运行 Virtualbox VM Centos 7、Apache 2.4.6 + PHP 7.1.12,并使用 VBox Guest Additions 共享文件夹配置将源代码目录安装到 VM。
It seems this issue is related to the VM and it's serving of the assets, some form of padding and culling if the file changed after being loaded.
重启httpd服务没有影响,只有在每次文件修改后重启虚拟机才能解决问题。
有没有其他人遇到过这个问题或能够重现它?
VM 设置(复制)
以下是我在学习如何创建和运行本地开发环境时建立的说明,如果您想尝试重现该问题:
https://docs.google.com/document/d/11cBF75hfcehB3np4nlLhc1EqIOKVchKIuQJyrvn8ztk
更新 1 - 26/11/17
我已经尝试从头开始重建一个新的虚拟机,仍然是同样的问题。
我注意到它也发生在 CSS 文件中,作为测试,我更改了以下代码:
.flexData.tools .settings:hover {
color: #0a0a0a;
}
/*# sourceMappingURL=flexData.css.map */
添加一个名为test的类:
.flexData.tools .settings:hover {
color: #0a0a0a;
}
.test {
color:blue;
}
/*# sourceMappingURL=flexData.css.map */
在服务器提供的文件末尾的结果如下所示:
.flexData.tools .settings:hover {
color: #0a0a0a;
}
/*# sourceMappingURL=flexData.css.map */
�������������������������
请注意注释前缺少测试类,注释后出现奇怪的字符。
然后我重新启动了虚拟机,然后在我的浏览器中按了 F5(刷新),字符消失了,我的测试类出现了:
.flexData.tools .settings:hover {
color: #0a0a0a; }
.test {
color:blue;
}
/*# sourceMappingURL=flexData.css.map */
我检查了 HTML 源代码响应,它没有对 PHP 的 HTML 输出执行此操作。
更新 2 - 26/11/17
I installed XAMP and tested all the issues above... None of the file modifications caused the error so this confirms there is some sort of file cache issue going here with the VM or the httpd service in the VM.
最佳答案
我有同样的问题,这是由 VM 引起的。
对于位置/ block 中的 NGINX 添加 sendfile off 设置。
location / {
...
sendfile off;
}
对于 Apache,在 httpd.conf 中查找 EnableSendfile 并将其设置为off:
EnableSendfile off
您必须重新启动服务才能使更改生效,需要硬刷新 Web 浏览器 (CTRL+F5) 才能看到更改生效。
EnableMMAP and EnableSendfile: On systems that support it, memory-mapping or the sendfile syscall may be used to deliver files. This usually improves server performance, but must be turned off when serving from networked-mounted filesystems or support for these functions is otherwise broken on your system.
关于Javascript 无效或意外的 token (\u0),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47444825/
为了将Cucumber用于命令行脚本,我按照提供的说明安装了arubagem。它在我的Gemfile中,我可以验证是否安装了正确的版本并且我已经包含了require'aruba/cucumber'在'features/env.rb'中为了确保它能正常工作,我写了以下场景:@announceScenario:Testingcucumber/arubaGivenablankslateThentheoutputfrom"ls-la"shouldcontain"drw"假设事情应该失败。它确实失败了,但失败的原因是错误的:@announceScenario:Testingcucumber/ar
似乎无法为此找到有效的答案。我正在阅读Rails教程的第10章第10.1.2节,但似乎无法使邮件程序预览正常工作。我发现处理错误的所有答案都与教程的不同部分相关,我假设我犯的错误正盯着我的脸。我已经完成并将教程中的代码复制/粘贴到相关文件中,但到目前为止,我还看不出我输入的内容与教程中的内容有什么区别。到目前为止,建议是在函数定义中添加或删除参数user,但这并没有解决问题。触发错误的url是http://localhost:3000/rails/mailers/user_mailer/account_activation.http://localhost:3000/rails/mai
我有两个Rails模型,即Invoice和Invoice_details。一个Invoice_details属于Invoice,一个Invoice有多个Invoice_details。我无法使用accepts_nested_attributes_forinInvoice通过Invoice模型保存Invoice_details。我收到以下错误:(0.2ms)BEGIN(0.2ms)ROLLBACKCompleted422UnprocessableEntityin25ms(ActiveRecord:4.0ms)ActiveRecord::RecordInvalid(Validationfa
rails中是否有任何规定允许站点的所有AJAXPOST请求在没有authenticity_token的情况下通过?我有一个调用Controller方法的JqueryPOSTajax调用,但我没有在其中放置任何真实性代码,但调用成功。我的ApplicationController确实有'request_forgery_protection'并且我已经改变了config.action_controller.consider_all_requests_local在我的environments/development.rb中为false我还搜索了我的代码以确保我没有重载ajaxSend来发送
我试图在我的网站上实现使用Facebook登录功能,但在尝试从Facebook取回访问token时遇到障碍。这是我的代码:ifparams[:error_reason]=="user_denied"thenflash[:error]="TologinwithFacebook,youmustclick'Allow'toletthesiteaccessyourinformation"redirect_to:loginelsifparams[:code]thentoken_uri=URI.parse("https://graph.facebook.com/oauth/access_token
假设您编写了一个类Sup,我决定将其扩展为SubSup。我不仅需要了解你发布的接口(interface),还需要了解你的私有(private)字段。见证这次失败:classSupdefinitialize@privateField="fromsup"enddefgetXreturn@privateFieldendendclassSub问题是,解决这个问题的正确方法是什么?看起来子类应该能够使用它想要的任何字段而不会弄乱父类(superclass)。编辑:equivalentexampleinJava返回"fromSup",这也是它应该产生的答案。 最佳答案
我遇到了一个非常奇怪的问题,我很难解决。在我看来,我有一个与data-remote="true"和data-method="delete"的链接。当我单击该链接时,我可以看到对我的Rails服务器的DELETE请求。返回的JS代码会更改此链接的属性,其中包括href和data-method。再次单击此链接后,我的服务器收到了对新href的请求,但使用的是旧的data-method,即使我已将其从DELETE到POST(它仍然发送一个DELETE请求)。但是,如果我刷新页面,HTML与"new"HTML相同(随返回的JS发生变化),但它实际上发送了正确的请求类型。这就是这个问题令我困惑的
我想知道我应该引用什么异常名称。我的日期无效。我检查了文档,但找不到。BeginDate.new(day,month,year)Rescueexceptionnamestatements 最佳答案 我认为您正在寻找ArgumentError.使用irb:>Date.new(2,-200,3)ArgumentError:invaliddatefrom(irb):11:in`new'from(irb):11所以beginDate.new(2,-200,3)rescueArgumentError#yourlogicend
我正在尝试创建密码规则来设计可恢复的密码更改。我通过passwords_controller.rb做了一个父类(superclass),但我需要在应用规则之前检查用户角色,但我所拥有的只是reset_password_token。 最佳答案 假设您的模型是用户:User.with_reset_password_token(your_token_here)Source 关于ruby-on-rails-设计通过reset_password_token获取用户,我们在StackOverflow
简单代码require'net/http'url=URI.parse('getjson/otherdatahere[link]')req=Net::HTTP::Get.new(url.to_s)res=Net::HTTP.start(url.host,url.port){|http|http.request(req)}putsres.body只是想知道如何在phpcURL中放置身份验证token,我是这样做的 curl_setopt($ch,CURLOPT_HTTPHEADER,array('Authorization:Bearerxxx'));//Bearertokenfora