1<?php 2 3namespace dokuwiki\Parsing\ParserMode; 4 5use dokuwiki\Parsing\Handler; 6 7class Windowssharelink extends AbstractMode 8{ 9 protected $pattern; 10 11 /** @inheritdoc */ 12 public function getSort() 13 { 14 return 350; 15 } 16 17 /** @inheritdoc */ 18 public function preConnect() 19 { 20 // The path-segment group is possessive: `[\w\-$]+` stops at each 21 // backslash, so successive segments never overlap and the group never 22 // needs to backtrack. Without it a long `\\host\a\b\c…` run makes the 23 // non-JIT PCRE engine retain one backtracking frame per segment. 24 $this->pattern = "\\\\\\\\\w+?(?:\\\\[\w\-$]+)++"; 25 } 26 27 /** @inheritdoc */ 28 public function connectTo($mode) 29 { 30 $this->Lexer->addSpecialPattern( 31 $this->pattern, 32 $mode, 33 'windowssharelink' 34 ); 35 } 36 37 /** @inheritdoc */ 38 public function handle($match, $state, $pos, Handler $handler) 39 { 40 $handler->addCall('windowssharelink', [$match, null], $pos); 41 return true; 42 } 43} 44