小编ton*_*nix的帖子

如何编写与嵌套括号匹配的递归正则表达式?

我正在尝试编写一个匹配嵌套括号的正则表达式,例如:

"(((text(text))))(text()()text)(casual(characters(#$%^^&&#^%#@!&**&#^*!@#^**_)))"
Run Code Online (Sandbox Code Playgroud)

应该匹配这样的字符串,因为所有嵌套的括号都是关闭的,而是:

"(((text)))(text)(casualChars*#(!&#*(!))"
Run Code Online (Sandbox Code Playgroud)

不应该或者更好的是,应该至少匹配第一个"(((text)))(text)"部分.

实际上,我的正则表达式是:

 $regex = '/( (  (\() ([^[]*?)  (?R)?  (\))  ){0,}) /x';
Run Code Online (Sandbox Code Playgroud)

但它并没有像我期待的那样正常工作.如何解决?我哪里错了?谢谢!

php regex

8
推荐指数
2
解决办法
7357
查看次数

谁能解释这些XSS测试字符串?

最近我发现这个关于XSS和Web应用程序安全性的教程 - > https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#XSS_Locator

在开始时,有一些字符串要注入,以测试站点是否容易受到xss的攻击.这些字符串是:

';alert(String.fromCharCode(88,83,83))//';alert(String.fromCharCode(88,83,83))//";
alert(String.fromCharCode(88,83,83))//";alert(String.fromCharCode(88,83,83))//--
></SCRIPT>">'><SCRIPT>alert(String.fromCharCode(88,83,83))</SCRIPT> 
Run Code Online (Sandbox Code Playgroud)

'';!--"<XSS>=&{()}
Run Code Online (Sandbox Code Playgroud)

我知道XSS的基本概念,但在这里我无法理解为什么在第一个字符串中重复'alert(String.fromCharCode(88,83,83))'以及为什么这些//'; //"; // - >需要注释(在搜索xss错误时以这种方式使用它们意味着什么特别?).在第二个字符串中,&{()}序列的目的是什么? ?

任何人都可以通过具体的例子来解释我这两个字符串应该如何工作以检索Web应用程序中的xss错误?在我链接的网站上的原因没有给出解释...

javascript xss

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

Apache FastCGI PHP中FastCgiExternalServer和FastCgiServer的区别?

请允许我声明我是FastCGI的新手.我的OS X机器上有MAMP的Apache.默认的PHP处理程序是Apache Handler 2.0(libphp5.so).我想改变FastCGI并遵循这里的答案:如何配置Apache在Ubuntu 12.04上通过终端运行PHP作为FastCGI?

我在httpd.conf的末尾添加了以下内容:

<IfModule mod_fastcgi.c>
   AddHandler php5.fcgi .php
   Action php5.fcgi /php5.fcgi
   Alias /php5.fcgi /Applications/MAMP/fcgi-bin/php5.fcgi
   FastCgiServer /Applications/MAMP/fcgi-bin/php5.fcgi -socket /Applications/MAMP/tmp/php-fcgi/php5-fpm.sock -pass-header Authorization -idle-timeout 3600
   #FastCgiExternalServer /Applications/MAMP/fcgi-bin/php5.fcgi -socket /Applications/MAMP/tmp/php-fcgi/php5-fpm.sock -pass-header Authorization -idle-timeout 3600
   <Directory /Applications/MAMP/fcgi-bin>
       Order allow,deny
         Allow from all
   </Directory> 
</IfModule>
Run Code Online (Sandbox Code Playgroud)

但是,正如您所看到的,FastCgiExternalServer已被注释掉.相反,我不得不使用FastCgiServer原因,否则Apache在尝试请求页面时会给我以下错误:

[星期五06月23日23:25:22] [错误] [客户端:: 1](2)没有这样的文件或目录:FastCGI:无法连接到服务器"/Applications/MAMP/fcgi-bin/php5.fcgi" : 连接失败

[星期五06月23日23:25:22 2016] [错误] [client :: 1] FastCGI:从服务器"/Applications/MAMP/fcgi-bin/php5.fcgi"收到的不完整标题(0字节)

/Applications/MAMP/fcgi-bin/php5.fcgi存在且其内容是:

#!/bin/bash
PHP_CGI=/Applications/MAMP/bin/php/php5.6.2/bin/php-cgi
exec $PHP_CGI
Run Code Online (Sandbox Code Playgroud)

什么之间的区别FastCgiServerFastCgiExternalServer,为什么FastCgiExternalServer在我的情况没有工作,但FastCgiServer …

php apache fastcgi mod-fastcgi

8
推荐指数
1
解决办法
7113
查看次数

为什么fadeIn(),fadeOut(),show(400),hide(400)动画在我的情况下不起作用?

我有一个div显示用户收到的通知,问题是我希望分别在用户收到通知并点击它以查看时显示淡入和淡出效果.

这是HTML:

<li class="recentChatUser" onclick="createChatWindow('User',id);">
    <div class="user_data">
      <div class="foto_profilo_utenti_recenti_container">
          <img src="./userimg.jpg" class="user_photo"/>
      </div>
      <span class="userName">User name</span>
        <div id="messages_notifications_$id$" class="message_notification">0</div>
    </div>
</li>
Run Code Online (Sandbox Code Playgroud)

每个列表项代表用户的朋友.div id ="messages_notifications_ $ id $"...包含来自用户的特定朋友的通知的数量,用户尚未阅读的通知的数量.$ id $是用户朋友的单义ID(因此0表示包含来自id = 1的用户的朋友的所有通知的div,依此类推).我使用长轮询向服务器恢复进行异步调用的通知的数量,该服务器从特定的朋友向用户返回带有所有消息的json.然后我使用JQuery使用朋友的id更新div的通知数量.

一切都很好,除非显示通知(我希望它以fadeIn()的方式显示,但它没有,似乎fadeOut()被执行但没有任何淡入淡出的动画,就像有一个通知它看起来是无条件的,而不是fadeIn(),因为我告诉它)当我点击列表中的项目我想使div id ="messages_notifications_ $ id $"以fadeOut()方式消失,然后我冲洗通知并将它们标记为已读,但fadeOut()不起作用(同样,通知div立即消失,但最奇怪的是fadeOut被调用因为它是我用来使消息通知的唯一方法div)...我甚至试过show(1000)而不是fadeIn()和hide(1000)而不是fadeOut,但它没有用.这是通过fadeIn()显示通知的代码,当我清理通知并淡出通知div时:

var notifyUserWithNewMessages = function(notifications) {
    for (var i = 0; i < notifications.length; i++) {
            var notification = notifications[i];
            var notificationDiv = $("#messagges_notifications_" + notification.fromid);
            notificationDiv.text(notification.counter);

            console.log(notificationDiv);
            // Showing the notification only if the list item is not selected and the notification div …
Run Code Online (Sandbox Code Playgroud)

javascript jquery

7
推荐指数
1
解决办法
655
查看次数

在Eclipse中安装新软件Luna始终提供错误没有找到包含的存储库:osgi.bundle,org.eclipse.net4j.jms.api?

我正在使用带有Eclipse Luna 4.4的STS(Spring Tool Suite),我注意到每次我尝试通过帮助 - >"安装新软件"安装某些东西(例如Apache IvyDE,Web Tools Platform)时,我收到以下错误:

An error occurred while collecting items to be installed
session context was:(profile=DefaultProfile, phase=org.eclipse.equinox.internal.p2.engine.phases.Collect, operand=, action=).
No repository found containing: osgi.bundle,org.eclipse.net4j.jms.api,3.1.100.v20140218-1709
Run Code Online (Sandbox Code Playgroud)

如何摆脱此错误并安装Eclipse的软件和插件?

编辑:这是它的样子:

在此输入图像描述

然后我点击"下一步",而eclipse加载:

在此输入图像描述

进度条上有"无法执行操作"消息,之后:

在此输入图像描述

然后我接受许可证,点击完成后我收到错误:

在此输入图像描述

java eclipse spring

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

为什么Tomcat服务器不使用web.xml文件作为Vaadin 7应用程序中使用的servlet配置?

当我使用web.xml作为应用程序中servlet的配置文件时,我无法启动Tomcat,这是文件的内容:

<?xml version="1.0" encoding="UTF-8"?>
<web-app
  id="WebApp_ID" version="3.0"
  xmlns="http://java.sun.com/xml/ns/j2ee" 
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
  xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
     http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">

  <servlet>
    <servlet-name>AppLifeServlet</servlet-name>
    <servlet-class>
        com.example.application_lifecycle_chapter_4_7.ApplicatationLifecycleUI.Servlet
    </servlet-class>
    <init-param>
      <param-name>UI</param-name>
      <param-value>com.example.application_lifecycle_chapter_4_7.ApplicationLifecycleUI</param-value>
    </init-param>
    <async-supported>true</async-supported>
  </servlet>

  <servlet>
      <servlet-name>MyPushyServlet</servlet-name>
      <servlet-class>
          com.example.application_lifecycle_chapter_4_7.MyPushyUI.Servlet
      </servlet-class>
      <init-param>
        <param-name>UI</param-name>
        <param-value>com.example.application_lifecycle_chapter_4_7.MyPushyUI</param-value>
      </init-param>
      <async-supported>true</async-supported>
  </servlet>    

  <servlet-mapping>
    <servlet-name>AppLifeServlet</servlet-name>
    <url-pattern>/AppLife/*</url-pattern>
  </servlet-mapping>

  <servlet-mapping>
      <servlet-name>AppLifeServlet</servlet-name>
      <url-pattern>/VAADIN/*</url-pattern>
  </servlet-mapping>

  <servlet-mapping>
      <servlet-name>MyPushyServlet</servlet-name>
      <url-pattern>/MyPushyUI/*</url-pattern>
  </servlet-mapping>
</web-app>
Run Code Online (Sandbox Code Playgroud)

为什么不起作用?Tomcat甚至无法启动,而是返回异常:

SEVERE: Failed to destroy end point associated with ProtocolHandler ["ajp-nio-8009"]
java.lang.NullPointerException
    at org.apache.tomcat.util.net.NioEndpoint.releaseCaches(NioEndpoint.java:307)
    at org.apache.tomcat.util.net.NioEndpoint.unbind(NioEndpoint.java:482)
    at org.apache.tomcat.util.net.AbstractEndpoint.destroy(AbstractEndpoint.java:795)
    at org.apache.coyote.AbstractProtocol.destroy(AbstractProtocol.java:531)
    at org.apache.catalina.connector.Connector.destroyInternal(Connector.java:1023)
    at org.apache.catalina.util.LifecycleBase.destroy(LifecycleBase.java:305)
    at org.apache.catalina.core.StandardService.destroyInternal(StandardService.java:588)
    at org.apache.catalina.util.LifecycleBase.destroy(LifecycleBase.java:305)
    at org.apache.catalina.core.StandardServer.destroyInternal(StandardServer.java:850)
    at org.apache.catalina.util.LifecycleBase.destroy(LifecycleBase.java:305)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:629) …
Run Code Online (Sandbox Code Playgroud)

java tomcat web.xml servlets vaadin

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

如何重置emacs以utf-8-unix字符编码保存文件?

我有个问题.我发现emacs最近停止使用默认字符集" utf-8-unix " 保存所有新文件.我不明白我做了什么,但是当我打开一个文件时,在迷你缓冲区上面我看到" - :---"而不是" -U:--- ",其中"U"表示该文件用utf-8-unix charset保存.如何重置emacs以在正确的编码系统中保存文件?

linux emacs encoding utf-8

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

如何将$ _SESSION变量传递给websocket服务器?

我在网上搜索了很多,但没有找到有用的线索.

我有一个websocket服务器和一个在我的本地机器上一起运行的Web服务器.

当客户端使用浏览器API'new WebSocket("ws:// localhost")'连接到它时,我需要将$ _SESSION数据传递给websocket服务器(请求使用反向代理发送到websocket,后者知道它当收到带有"升级"标题的请求时.

关键是客户端成功连接到ws服务器,但我还需要使用HTTP Web服务器设置的$ _SESSION变量来恢复其SESSION数据.

其实我的情况是这样的(我正在使用Ratchet库):

use Ratchet\Server\IoServer;
use Ratchet\Http\HttpServer;
use Ratchet\WebSocket\WsServer;
use MyApp\MyAppClassChat;

require dirname(__DIR__) . '/vendor/autoload.php';

$server = IoServer::factory(new HttpServer(new WsServer(new MyAppClass())), 8080);
$server->run();
Run Code Online (Sandbox Code Playgroud)

MyAppClass非常简单:

 <?php
namespace MyAppClass;
use Ratchet\MessageComponentInterface;
use Ratchet\ConnectionInterface;

class MyAppClass implements MessageComponentInterface {

    protected $clients;

    public function __construct() {
        $this->clients = new \SplObjectStorage;
    }

    public function onOpen(ConnectionInterface $conn) {
            /* I would like to put recover the session infos of the clients here
               but the session_start() call returns an empty …
Run Code Online (Sandbox Code Playgroud)

php apache session websocket

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

终端 - 即使未找到匹配项,为什么 grep 的退出命令为 0?

我有这个命令:

grep -E '^nothing' List.txt | echo $?
Run Code Online (Sandbox Code Playgroud)

这里 grep 不匹配任何东西,我只是输出它的退出代码。根据 grep 的文档:

通常,如果选择了一行,退出状态为 0,如果没有选择任何行,则退出状态为 1,如果发生错误,则退出状态为 2。但是,如果使用 -q 或 --quiet 或 --silent 选项并选择了一行,即使发生错误,退出状态也是 0。其他 grep 实现可能会在出错时以大于 2 的状态退出。

但:

prompt:user$ grep -E '^nothing' List.txt | echo $?
0
prompt:user$
Run Code Online (Sandbox Code Playgroud)

但是为什么即使匹配不存在,我也会得到 0 作为输出,我不应该得到预期的 1 退出代码吗?

shell terminal grep exit-code

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

在插入过程中逐步存储从根节点到多路树的节点的路径,因此存储操作不会具有O(n)的复杂度

我想问一问,在插入新节点期间,是否有人知道一种存储从根节点到多路树的新节点的路径的有效方法。例如,如果我有以下树:

多路树

对于每个节点,我目前通过以下方式存储从根节点到根节点的路径的数组,方法是通过int为每个深度相同的子代分配一个唯一的ID:

Root node -> [1]

Depth 1, child 1 of root -> [1, 1]
Depth 1, child 2 of root -> [1, 2]

Depth 2, child 1 of parent 1 -> [1, 1, 1]
Depth 2, child 2 of parent 1 -> [1, 1, 2]
Depth 2, child 3 of parent 1 -> [1, 1, 3]
Depth 2, child 1 of parent 2 -> [1, 2, 4]
Depth 2, child 2 of parent 2 -> [1, 2, …
Run Code Online (Sandbox Code Playgroud)

algorithm tree multiway-tree treepath

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