Last modified: 2007-03-23 23:34:08 UTC

Wikimedia Bugzilla is closed!

Wikimedia has migrated from Bugzilla to Phabricator. Bug reports should be created and updated in Wikimedia Phabricator instead. Please create an account in Phabricator and add your Bugzilla email address to it.
Wikimedia Bugzilla is read-only. If you try to edit or create any bug report in Bugzilla you will be shown an intentional error message.
In order to access the Phabricator task corresponding to a Bugzilla report, just remove "static-" from its URL.
You could still run searches in Bugzilla or access your list of votes but bug reports will obviously not be up-to-date in Bugzilla.
Bug 9129 - [patch] Attributes with Links
[patch] Attributes with Links
Status: RESOLVED FIXED
Product: MediaWiki extensions
Classification: Unclassified
Semantic MediaWiki (Other open bugs)
unspecified
All All
: Normal normal (vote)
: ---
Assigned To: Nobody - You can work on this!
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2007-02-28 16:17 UTC by Smylers
Modified: 2007-03-23 23:34 UTC (History)
0 users

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments
fix (604 bytes, patch)
2007-02-28 16:21 UTC, Smylers
Details

Description Smylers 2007-02-28 16:17:27 UTC
Currently in Semantic MediaWiki an attribute value can't contain links to other
pages in their text, such as:

  [[flavour:=tastes like [[chicken]]]]

It displays correctly in the page text, exactly as though it had simply been
written:

  tastes like [[chicken]]

with 'chicken' being a link to that page.

However the attribute is assigned the text:

  tastes like [[chicken

and that's how it displays in the 'Facts' box and other places.

The problem is that the pattern matching attribute declarations stops at the
first ']]'.  The below patch fixes this so that it will skip over any matching
pairs of '[[' and ']]' in the attribute value.

Basically where the pattern had this, to match all characters up to the next
pipe or closing square bracket (and store them):

  ([^|\]]*)

I've changed it to this:

  ((?:[^|\]]|\[\[[[^]]*\]\])*)

which says that you can have as many repetitions as you want of either of these
in any combination:

* a sequence of characters which doesn't include a pipe or closing
  square bracket
* '[[' then a sequence of characters which doesn't include a
  closing square bracket, then ']]'

So when it reaches the '[[' of chicken the second of those alternatives is
chosen and it gobbles up everything up to and including the ']]' at the end of
chicken, leaving the final ']]' to terminate the attribute declaration.

I hope this is helpful, and that it can be incorporated into a forthcoming
release of Semantic MediaWiki.  Please let me know if you have any questions.

Smylers

--- SMW_Hooks.php.orig	Wed Feb 28 15:51:54 2007
+++ SMW_Hooks.php	Wed Feb 28 15:52:24 2007
@@ -34,7 +34,7 @@
 		$text = preg_replace_callback($semanticLinkPattern,
'smwfParseRelationsCallback', $text);
 
 		// Parse links to extract attribute values
-		$semanticLinkPattern = '(\[\[(([^:][^]]*):=)+([^\|\]]*)(\|([^]]*))?\]\])';
+		$semanticLinkPattern =
'(\[\[(([^:][^]]*):=)+((?:[^|\[\]]|\[\[[^]]*\]\])*)(\|([^]]*))?\]\])';
 		$text = preg_replace_callback($semanticLinkPattern,
'smwfParseAttributesCallback', $text);
 
 		// print the results if enabled (we have to parse them in any case, in order to
Comment 1 Smylers 2007-02-28 16:21:06 UTC
Created attachment 3278 [details]
fix

Patch attached; I only inlined in the original message because I couldn't see
anywhere to upload it.
Comment 2 S Page 2007-03-05 10:12:59 UTC
Hey Smylers, thanks for the patch, it works for me but it changes the behavior
of edge cases like [[flavor:=tastes like [pigeon]]].  So I'm comfortable
checking it in without review from someone else.

I assume you know you could also have a relation, [[tastes like::chicken]].
Comment 3 S Page 2007-03-05 10:13:37 UTC
Hey Smylers, thanks for the patch, it works for me but it changes the behavior
of edge cases like [[flavor:=tastes like [pigeon]]].  So I'm not comfortable
checking it in without review from someone else.

I assume you know you could also have a relation, [[tastes like::chicken]].
Comment 4 Markus Krötzsch 2007-03-23 23:34:08 UTC
OK, I have applied this patch, and links in attribute texts work now. However,
the quick search is disabled for those cases, since it is not possible to create
an internal link which contains symbols like [ and ]. This is probably not very
problematic, since attribute values containing links should be long passages,
for which one normally does not search. One could still fix this detail if needed.

Also, the attribut contents is stored as wiki code internally, and will be
exported in this way.

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links