Issues (69)

Security Analysis    no request data  

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

EMT/EMTTretQuote.php (7 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
/**
4
* Evgeny Muravjev Typograph, http://mdash.ru
5
* Version: 3.4 Gold Master
6
* Release Date: September 20, 2014
7
* Authors: Evgeny Muravjev & Alexander Drutsa  
8
*/
9
10
namespace Fenrizbes\TypographBundle\EMT;
11
12
/**
13
 * @see EMTTret
14
 */
15
16
class EMTTretQuote extends EMTTret
17
{
18
    /**
19
     * Базовые параметры тофа
20
     *
21
     * @var array
22
     */
23
    public $title = "Кавычки";
24
25
26
    public $rules = array(
27
        'quotes_outside_a' => array(
28
            'description'	=> 'Кавычки вне тэга <a>',
29
            //'pattern' 		=> '/(\<%%\_\_.+?\>)\"(.+?)\"(\<\/%%\_\_.+?\>)/s',
0 ignored issues
show
Unused Code Comprehensibility introduced by
67% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
30
            'pattern' 		=> '/(\<%%\_\_[^\>]+\>)\"(.+?)\"(\<\/%%\_\_[^\>]+\>)/s',
31
            'replacement' 	=> '"\1\2\3"'
32
        ),
33
34
        'open_quote' => array(
35
            'description'	=> 'Открывающая кавычка',
36
            'pattern' 		=> '/(^|\(|\s|\>|-)((\"|\\\")+)(\S+)/iue',
37
            'replacement' 	=> '$m[1] . str_repeat(self::QUOTE_FIRS_OPEN, substr_count($m[2],"\"") ) . $m[4]'
38
        ),
39
        'close_quote' => array(
40
            'description'	=> 'Закрывающая кавычка',
41
            'pattern' 		=> '/([a-zа-яё0-9]|\.|\&hellip\;|\!|\?|\>|\)|\:|\+|\%|\@|\#|\$|\*)((\"|\\\")+)(\.|\&hellip\;|\;|\:|\?|\!|\,|\s|\)|\<\/|\<|$)/uie',
42
            'replacement' 	=> '$m[1] . str_repeat(self::QUOTE_FIRS_CLOSE, substr_count($m[2],"\"") ) . $m[4]'
43
        ),
44
        'close_quote_adv' => array(
45
            'description'	=> 'Закрывающая кавычка особые случаи',
46
            //'pattern' 		=> '/([a-zа-яё0-9]|\.|\&hellip\;|\!|\?|\>|\)|\:)((\"|\\\"|\&laquo\;)+)(\<.+?\>)(\.|\&hellip\;|\;|\:|\?|\!|\,|\s|\)|\<\/|$)/uie',
0 ignored issues
show
Unused Code Comprehensibility introduced by
67% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
47
            'pattern' 		=>
48
            array(
49
                '/([a-zа-яё0-9]|\.|\&hellip\;|\!|\?|\>|\)|\:|\+|\%|\@|\#|\$|\*)((\"|\\\"|\&laquo\;)+)(\<[^\>]+\>)(\.|\&hellip\;|\;|\:|\?|\!|\,|\)|\<\/|$| )/uie',
50
                '/([a-zа-яё0-9]|\.|\&hellip\;|\!|\?|\>|\)|\:|\+|\%|\@|\#|\$|\*)(\s+)((\"|\\\")+)(\s+)(\.|\&hellip\;|\;|\:|\?|\!|\,|\)|\<\/|$| )/uie',
51
                '/\>(\&laquo\;)\.($|\s|\<)/ui',
52
                '/\>(\&laquo\;),($|\s|\<|\S)/ui',
53
                '/\>(\&laquo\;):($|\s|\<|\S)/ui',
54
                '/\>(\&laquo\;);($|\s|\<|\S)/ui',
55
                '/\>(\&laquo\;)\)($|\s|\<|\S)/ui',
56
                '/((\"|\\\")+)$/uie',
57
            ),
58
            'replacement' 	=>
59
            array(
60
                '$m[1] . str_repeat(self::QUOTE_FIRS_CLOSE, substr_count($m[2],"\"")+substr_count($m[2],"&laquo;") ) . $m[4]. $m[5]',
61
                '$m[1] .$m[2]. str_repeat(self::QUOTE_FIRS_CLOSE, substr_count($m[3],"\"")+substr_count($m[3],"&laquo;") ) . $m[5]. $m[6]',
62
                '>&raquo;.\2',
63
                '>&raquo;,\2',
64
                '>&raquo;:\2',
65
                '>&raquo;;\2',
66
                '>&raquo;)\2',
67
                'str_repeat(self::QUOTE_FIRS_CLOSE, substr_count($m[1],"\"") )',
68
            ),
69
        ),
70
        'open_quote_adv' => array(
71
            'description'	=> 'Открывающая кавычка особые случаи',
72
            'pattern' 		=> '/(^|\(|\s|\>)(\"|\\\")(\s)(\S+)/iue',
73
            'replacement' 	=> '$m[1] . self::QUOTE_FIRS_OPEN .$m[4]'
74
        ),
75
        'close_quote_adv_2' => array(
76
            'description'	=> 'Закрывающая кавычка последний шанс',
77
            'pattern' 		=> '/(\S)((\"|\\\")+)(\.|\&hellip\;|\;|\:|\?|\!|\,|\s|\)|\<\/|\<|$)/uie',
78
            'replacement' 	=> '$m[1] . str_repeat(self::QUOTE_FIRS_CLOSE, substr_count($m[2],"\"") ) . $m[4]'
79
        ),
80
        'quotation' => array(
81
            'description'	=> 'Внутренние кавычки-лапки и дюймы',
82
            'function' => 'build_sub_quotations'
83
        ),
84
    );
85
86
    protected function inject_in($pos, $text, &$thetext)
87
    {
88
        for($i=0;$i<strlen($text);$i++) $thetext[$pos+$i] = $text[$i];
89
    }
90
91
    protected function build_sub_quotations()
92
    {
93
        global $__ax,$__ay;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
94
95
        $exp = strpos($this->_text, "</cA===>")!==false ? "</cA===>" : (strpos($this->_text,"\r\n")!==false ? "\r\n\r\n" :"\n\n");
96
97
        $texts_in = explode($exp, $this->_text);
98
        $texts_out = array();
99
100
        foreach($texts_in as $textx) {
101
102
            $okposstack = array('0');
103
            $okpos = 0;
104
            $level = 0;
105
            $off = 0;
106
            while(true)
107
            {
108
                $p = EMTLib::strpos_ex($textx, array("&laquo;", "&raquo;"), $off);
109
                if($p===false) break;
110 View Code Duplication
                if($p['str'] == "&laquo;")
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
111
                {
112
                    if($level>0) if(!$this->is_on('no_bdquotes')) $this->inject_in($p['pos'], self::QUOTE_CRAWSE_OPEN, $textx);
113
                    $level++;
114
                }
115 View Code Duplication
                if($p['str'] == "&raquo;")
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
116
                {
117
                    $level--;
118
                    if($level>0) if(!$this->is_on('no_bdquotes')) $this->inject_in($p['pos'], self::QUOTE_CRAWSE_CLOSE, $textx);
119
                }
120
                $off = $p['pos']+strlen($p['str']);
121
                if($level == 0)
122
                {
123
                    $okpos = $off;
124
                    array_push($okposstack, $okpos);
125
                } elseif($level<0) // уровень стал меньше нуля
126
                {
127
                    if(!$this->is_on('no_inches'))
128
                    {
129
                        do{
130
                            $lokpos = array_pop($okposstack);
131
                            $k = substr($textx, $lokpos, $off-$lokpos);
132
                            $k = str_replace(self::QUOTE_CRAWSE_OPEN, self::QUOTE_FIRS_OPEN, $k);
133
                            $k = str_replace(self::QUOTE_CRAWSE_CLOSE, self::QUOTE_FIRS_CLOSE, $k);
134
                            //$k = preg_replace("/(^|[^0-9])([0-9]+)\&raquo\;/ui", '\1\2&Prime;', $k, 1, $amount);
0 ignored issues
show
Unused Code Comprehensibility introduced by
62% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
135
136
                            $amount = 0;
137
                            $__ax = preg_match_all("/(^|[^0-9])([0-9]+)\&raquo\;/ui", $k, $m);
138
                            $__ay = 0;
139
                            if($__ax)
140
                            {
141
                                $k = preg_replace_callback("/(^|[^0-9])([0-9]+)\&raquo\;/ui",
142
                                    create_function('$m','global $__ax,$__ay; $__ay++; if($__ay==$__ax){ return $m[1].$m[2]."&Prime;";} return $m[0];'),
0 ignored issues
show
Security Best Practice introduced by
The use of create_function is highly discouraged, better use a closure.

create_function can pose a great security vulnerability as it is similar to eval, and could be used for arbitrary code execution. We highly recommend to use a closure instead.

// Instead of
$function = create_function('$a, $b', 'return $a + $b');

// Better use
$function = function($a, $b) { return $a + $b; }
Loading history...
143
                                    $k);
144
                                $amount = 1;
145
                            }
146
147
148
149
                        } while(($amount==0) && count($okposstack));
150
151
                        // успешно сделали замену
152
                        if($amount == 1)
153
                        {
154
                            // заново просмотрим содержимое
155
                            $textx = substr($textx, 0, $lokpos). $k . substr($textx, $off);
156
                            $off = $lokpos;
157
                            $level = 0;
158
                            continue;
159
                        }
160
161
                        // иначе просто заменим последнюю явно на &quot; от отчаяния
162
                        if($amount == 0)
163
                        {
164
                            // говорим, что всё в порядке
165
                            $level = 0;
166
                            $textx = substr($textx, 0, $p['pos']). '&quot;' . substr($textx, $off);
167
                            $off = $p['pos'] + strlen('&quot;');
168
                            $okposstack = array($off);
169
                            continue;
170
                        }
171
                    }
172
                }
173
174
175
            }
176
            // не совпало количество, отменяем все подкавычки
177
            if($level != 0 ){
178
179
                // закрывающих меньше, чем надо
180
                if($level>0)
181
                {
182
                    $k = substr($textx, $okpos);
183
                    $k = str_replace(self::QUOTE_CRAWSE_OPEN, self::QUOTE_FIRS_OPEN, $k);
184
                    $k = str_replace(self::QUOTE_CRAWSE_CLOSE, self::QUOTE_FIRS_CLOSE, $k);
185
                    $textx = substr($textx, 0, $okpos). $k;
186
                }
187
            }
188
            $texts_out[] = $textx;
189
        }
190
        $this->_text = implode($exp, $texts_out);
191
    }
192
}
193