RegexpException #4 Malformed UTF-8 data

- MzK
 - Člen | 127
 
Ladenka mi posila nejake error logy na webu.
Malformed UTF-8 data (pattern: #index\.php/?$#Aiu)
$subject
string(26) „text/windows+font+kurz\xc3/“
$pattern
string(18) „#index\.php/?$#Aiu“
„/text/windows+font+kurz%C3“
A stránka se samozřejmě nezobrazí → buď chyba 500 nebo bila stranka dle nastaveni.

- Mikulas Dite
 - Člen | 756
 
Nelíbí se tomu \xc3, ten string není prostě v pořádku.
Možná nekrátíš přes mb_ / iconv verze a zůstává ti tam část
původních znaků.

- MzK
 - Člen | 127
 
Ještě přikládám log o chybě:
<?php
Call stack ▼
   1.
      Nette/String.php (330) source ►  String:: checkPreg (arguments ►)
      $res
      int(0)
      $pattern
      string(18) "#index\.php/?$#Aiu"
      Line 323:         * @param  int
      Line 324:         * @param  int
      Line 325:         * @return mixed
      Line 326:         */
      Line 327:        public static function match($subject, $pattern, $flags = 0, $offset = 0)
      Line 328:        {
      Line 329:            $res = preg_match($pattern, $subject, $m, $flags, $offset);
      Line 330:            self::checkPreg($res, $pattern);
      Line 331:            if ($res) {
      Line 332:                return $m;
      Line 333:            }
      Line 334:        }
      Line 335:
      Line 336:
      Line 337:
   2.
      Routers/Route.php (151) source ►  String:: match (arguments ►)
      $subject
      string(19) "hledej/mp3+ke+sta\xc5/"
      $pattern
      string(18) "#index\.php/?$#Aiu"
      Line 144:                $path = $uri->getPath();
      Line 145:            }
      Line 146:
      Line 147:            if ($path !== '') {
      Line 148:                $path = rtrim($path, '/') . '/';
      Line 149:            }
      Line 150:
      Line 151:            if (!$matches = String::match($path, $this->re)) {
      Line 152:                // stop, not matched
      Line 153:                return NULL;
      Line 154:            }
      Line 155:
      Line 156:            // deletes numeric keys, restore '-' chars
      Line 157:            $params = array();
      Line 158:            foreach ($matches as $k => $v) {
   3.
      Routers/MultiRouter.php (46) source ►  Route-> match (arguments ►)
      $httpRequest
      object(HttpRequest) (9) ► {
         "query" protected => array(0)
         "post" protected => array(0)
         "files" protected => array(0)
         "cookies" protected => array(0)
         "uri" protected => object(UriScript) (10) ► {
            "scriptPath" private => string(1) "/"
            "scheme" private => string(4) "http"
            "user" private => string(0) ""
            "pass" private => string(0) ""
            "port" private => int(80)
            "path" private => string(19) "/hledej/mp3+ke+sta\xc5"
            "query" private => string(0) ""
            "fragment" private => string(0) ""
            "frozen" private => bool(TRUE)
         }
         "originalUri" protected => object(Uri) (9) ► {
            "scheme" private => string(4) "http"
            "user" private => string(0) ""
            "pass" private => string(0) ""
            "port" private => int(80)
            "path" private => string(21) "/hledej/mp3+ke+sta%C5"
            "query" private => string(0) ""
            "fragment" private => string(0) ""
            "frozen" private => bool(TRUE)
         }
         "headers" protected => array(5) ▼ {
            "user-agent" => string(92) "Mozilla/5.0 (compatible; DotBot/1.1; http://www.dotnetdotcom.org/, crawler@dotnetdotcom.org)"
            "accept" => string(3) "*/*"
            "accept-encoding" => string(4) "gzip"
            "accept-charset" => string(36) "utf-8;q=0.7,iso-8859-1;q=0.2,*;q=0.1"
         }
         "uriFilter" protected => array(2) ▼ {
            5 => array(1) ▼ {
               "#/{2,}#" => string(1) "/"
            }
            0 => array(0)
         }
         "encoding" protected => string(5) "UTF-8"
      }
      Line 39:         * Maps HTTP request to a PresenterRequest object.
      Line 40:         * @param  IHttpRequest
      Line 41:         * @return PresenterRequest|NULL
      Line 42:         */
      Line 43:        public function match(IHttpRequest $httpRequest)
      Line 44:        {
      Line 45:            foreach ($this->routes as $route) {
      Line 46:                $appRequest = $route->match($httpRequest);
      Line 47:                if ($appRequest !== NULL) {
      Line 48:                    return $appRequest;
      Line 49:                }
      Line 50:            }
      Line 51:            return NULL;
      Line 52:        }
      Line 53:
   4.
      Application/Application.php (122) source ►  MultiRouter-> match (arguments ►)
      $httpRequest
      object(HttpRequest) (9) ► {
         "query" protected => array(0)
         "post" protected => array(0)
         "files" protected => array(0)
         "cookies" protected => array(0)
         "uri" protected => object(UriScript) (10) ► {
            "scriptPath" private => string(1) "/"
            "scheme" private => string(4) "http"
            "user" private => string(0) ""
            "pass" private => string(0) ""
            "port" private => int(80)
            "path" private => string(19) "/hledej/mp3+ke+sta\xc5"
            "query" private => string(0) ""
            "fragment" private => string(0) ""
            "frozen" private => bool(TRUE)
         }
         "originalUri" protected => object(Uri) (9) ► {
            "scheme" private => string(4) "http"
            "user" private => string(0) ""
            "pass" private => string(0) ""
            "port" private => int(80)
            "path" private => string(21) "/hledej/mp3+ke+sta%C5"
            "query" private => string(0) ""
            "fragment" private => string(0) ""
            "frozen" private => bool(TRUE)
         }
         "headers" protected => array(5) ▼ {
            "user-agent" => string(92) "Mozilla/5.0 (compatible; DotBot/1.1; http://www.dotnetdotcom.org/, crawler@dotnetdotcom.org)"
            "accept" => string(3) "*/*"
            "accept-encoding" => string(4) "gzip"
            "accept-charset" => string(36) "utf-8;q=0.7,iso-8859-1;q=0.2,*;q=0.1"
         }
         "uriFilter" protected => array(2) ▼ {
            5 => array(1) ▼ {
               "#/{2,}#" => string(1) "/"
            }
            0 => array(0)
         }
         "encoding" protected => string(5) "UTF-8"
      }
      Line 115:                            $router[] = new SimpleRouter(array(
      Line 116:                                'presenter' => 'Default',
      Line 117:                                'action' => 'default',
      Line 118:                            ));
      Line 119:                        }
      Line 120:
      Line 121:                        // routing
      Line 122:                        $request = $router->match($httpRequest);
      Line 123:                        if (!($request instanceof PresenterRequest)) {
      Line 124:                            $request = NULL;
      Line 125:                            throw new BadRequestException('No route for HTTP request.');
      Line 126:                        }
      Line 127:
      Line 128:                        if (strcasecmp($request->getPresenterName(), $this->errorPresenter) === 0) {
      Line 129:                            throw new BadRequestException('Invalid request.');
   5.
      app/bootstrap.php (108) source ►  Application-> run ()
      Line 101:        Form::FILLED => "Pole '%label' musí být vyplněné.",
      Line 102:        Form::RANGE => "Pole '%label' musí být v rozsahu od %d do %d",
      Line 103:        Form::EMAIL => "Pole '%label' musí být validní email",
      Line 104:        Form::URL => "Pole '%label' musí být validní URL",
      Line 105:    );
      Line 106:    $application->errorPresenter = "Error";
      Line 107:
      Line 108:    $application->run();
      Line 109:    ?>
   6.
      blog/index.php (48) source ►  require (arguments ►)
?>
Z toho jsem vyčetl, že nějaký
DotBot/1.1; http://www.dotnetdotcom.org/, crawler@dotnetdotcom.org
zkouší paznaky v URL a tím pádem vyvolává chybu.

- Mikulas Dite
 - Člen | 756
 
Jak sem říkal, jakékoli úpravy dělej přes mb_/iconv verze (potažmo Nette/String). Ničím jiným to být nemůže, někde se ten string prostě upravuje.
Edit: Nette speciální znaky v url zvládá, třeba ☖,
radši sem si to teď ověřil.
Editoval Mikulas Dite (8. 7. 2010 20:09)

- MzK
 - Člen | 127
 
Ale já žádné úpravy v aplikaci toho stringu nedělám. To dělá
framework sám viz trasování chyby:
bootstrap.php (122) source ► Application→ run ()
Application/Application.php (122) source ► MultiRouter→ match (arguments
►)
Routers/MultiRouter.php (46) source ► Route→ match (arguments ►)
Routers/Route.php (151) source ► String:: match (arguments ►)
Nette/String.php (330) source ► String:: checkPreg (arguments ►)
No nic, jdu debugovat a zkoumat