On Freitag, 8. August 2008, Rolf Lampa wrote:
>     Markus wrote:
>     ------------------------
>
>     [[property::Some [[link]] to another page]]
>     ...
>
>
>     If you feel more comfortable with the potential error, then you can
>     activate
>     support for nested links again with the new setting
>
>     $smwgLinksInValues = true;
>
>     Unfortunately, I currently see no easy way to enable embedded links
>     without
>     making a slightly more complex pattern that has potential to kill
>     PHP. For
>     details on the underlying problem, see [1] -- half of the bug
>     reports there
>     relate to the issue of crashes for pattern matching in long strings.
>
>
>
> Hm, could it be fixed using hard coding instead? 

Feel free to experiment. The code for pattern matching is in SMW_Hooks.php, 
function smwfParserHook().

> At least the brackets?. 
> What is the current pattern and which cases does it cover?

The default pattern now is

/\[\[                 # Beginning of the link
 (?:([^:][^]]*):[=:])+ # Property name (or a list of those)
 ([^\[\]]*)            # content: anything but [, |, ]
\]\]                  # End of link
/xu

It covers anything but syntax with [ and ] in property values. The alternative 
(optional) pattern is

/\[\[                 # Beginning of the link
(?:([^:][^]]*):[=:])+ # Property name (or a list of those)
(                     # After that:
  (?:[^|\[\]]         #   either normal text (without |, [ or ])
  |\[\[[^]]*\]\]      #   or a [[link]]
  |\[[^]]*\]          #   or an [external link]
)*)                   # all this zero or more times
(?:\|([^]]*))?        # Display text (like "text" in [[link|text]]), optional
\]\]                  # End of link
/xu

It covers nested [[...]] and [...], and has special treatment for the final | 
(to distinguish it from | in nested links).


>
> Regex tends to get into deep trouble when trying to balance complex
> nested brackets.

Yes, my tests also showed that simplifying the regexp is not just a little 
better, but allows for much larger property values (not just twice or ten 
times the size) without any errors.

Regards,

Markus

>
> Regards,
>
> // Rolf Lampa
>
>
>
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's
> challenge Build the coolest Linux based applications with Moblin SDK & win
> great prizes Grand prize is a trip for two to an Open Source event anywhere
> in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/
> _______________________________________________
> Semediawiki-devel mailing list
> Semediawiki-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/semediawiki-devel



-- 
Markus Krötzsch
Semantic MediaWiki    http://semantic-mediawiki.org
http://korrekt.org    [EMAIL PROTECTED]

Attachment: signature.asc
Description: This is a digitally signed message part.

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Semediawiki-devel mailing list
Semediawiki-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/semediawiki-devel

Reply via email to