Commit graph

101 commits

Author SHA1 Message Date
Brion Vibber
1c9ebd8072 Pulling r45473 back for now "Reduce code duplication correctly this time"
Let's hold off on further section anchor generation changes until we have decent test cases covering the different ways we we stuff through...
2009-01-07 04:23:51 +00:00
Aryeh Gregor
da5d1b714f Reduce code duplication correctly this time
This reverts r45470 and fixes the problems it identified.  Things should
now work as they always used to, but with less code duplication, and
with $wgEnforceHtmlIds = false working correctly as well.
2009-01-07 00:41:03 +00:00
Brion Vibber
4b6945cb8a Reverting r45341 " Use Sanitizer::escapeId() in another place Reduce code duplication some more, and fix section redirect after edit
when $wgEnforceHtmlIds is off."

This produces non-matching stuff like "#_Rock_on_dudes_" for == ''Rock on'' dudes ==.
2009-01-07 00:00:45 +00:00
Aryeh Gregor
72e98e4e6a When $wgEnforceHtmlIds=false, add legacy anchors
This means that old links will still work in a lot of cases.  However,
if the legacy anchor is invalid XML, we omit it.  In particular, on
non-Latin wikis, practically all old section links (from external
sources or using external links) are likely to break, since the first
character of legacy anchors starting with a non-ASCII character will be
".", which is invalid in XML as well as in HTML4.
2009-01-05 15:59:46 +00:00
Aryeh Gregor
4fde66f28d Refactor somewhat so that escapeId() works right
r45267 commented out the logic prohibiting numbers and so on at the
start of id's.  I've uncommented this logic, but passed 'noninitial' as
an option to escapeId() in all necessary circumstances.  Shouldn't
change behavior, this is to simplify some further work I'm about to do.
2009-01-05 15:59:35 +00:00
Aryeh Gregor
9bfa528584 Use Sanitizer::escapeId() in another place
Reduce code duplication some more, and fix section redirect after edit
when $wgEnforceHtmlIds is off.
2009-01-02 20:30:53 +00:00
Brion Vibber
c5d575e091 Follow-up to r45174: (bug 16806) Fix regression from r44524 that caused links to files to not get added to mLinks in ParserOutput, which caused them to not be included in LinksUpdate::LinksUpdate(), and not added to pagelinks.
Fixes other cases broken by Parser's assumptions failing to hold after change in Title::isAlwaysKnown()'s behavior:
* Links to invalid Special: pages were being recorded, but shouldn't
* Links to valid MediaWiki: pages were no longer recorded

Instead of the NS_FILE special-case in r45174, I'm just tossing *all* isAlwaysKnown links over to ParserOutput::addLink(), and letting the latter worry about what types of titles it won't record.
Just for good measure, in case any NS_MEDIA titles make it into ParserOutput::addLink() they'll be normalized to NS_FILE.
2009-01-01 00:05:08 +00:00
Alex Z
caa5d0d189 (bug 16806) Fix regression from r44524 that caused links to files to not get added to mLinks in ParserOutput, which caused them to not be included in LinksUpdate::LinksUpdate(), and not added to pagelinks. 2008-12-30 05:34:37 +00:00
Aryeh Gregor
d7371cc695 Optionally allow non-HTML4-compatible ids
This adds a config option, $wgEnforceHtmlIds, true by default.  If this
is set to false, all characters that are allowed in XML ids are let
through in header ids and manually-specified ids.  In particular, this
should include all alphabetic and numeric characters.

Some remaining issues to work out:

* This will cause backward-compatibility issues for some types of links
and references: links from non-MediaWiki sources, links from MediaWiki
sources running a different version, external links, and references from
stylesheets/scripts.  These could be partially alleviated by having a
second <a name="" id=""> for headers where the two versions differ, but
it would remain an issue for manually-specified id's.
* Any invalid characters are now, effectively, stripped (replaced with
underscores).  This might cause problems if some writing systems are
invalid in id's for some reason: we'll want to double-check the list of
prohibited characters carefully.
* Some user agents might not support these links.  IE5 appears to, and
so do recent versions of Opera and Firefox, but I didn't do extensive
testing.
* Not tested extensively, there are probably some bugs.

I think this would be good to enable on testwiki for the moment to see
how it goes.

No parser test regressions.  No change to RELEASE-NOTES, we can add that
when the option is enabled by default (ideally, removed entirely).
2008-12-30 00:22:34 +00:00
Aryeh Gregor
69d11310ff Improve ugly interface for Sanitizer::escapeId()
Calling it with no extra arguments will now assume that you're escaping
a whole id, not an id fragment, which is safer.  Also, instead of ugly
bitfield-based options, I've changed the options to use an array of
strings.  I fixed all callers in trunk.  Out-of-tree callers that were
using Sanitizer::NONE will get correct behavior, while those that were
calling it with no arguments will get slightly changed behavior (an x
will be prepended).  I think this is harmless enough that we can skip
back-compat cruft here.

This should cause no visible changes.  No parser test regressions.
2008-12-30 00:22:14 +00:00
Aryeh Gregor
ef56978780 Prepend x to section ids not starting with [a-z]
This will break any preexisting links to such sections (other than
those generated by the software, of course).  There should be no parser
test regressions.
2008-12-28 00:05:14 +00:00
Chad Horohoe
be374a912a War on wfElement() and friends. Call the Xml members directly, rather than using old wrappers. 2008-12-14 19:14:21 +00:00
Ilmari Karonen
0c9e9c8e7a (Actually, we can simplify that a bit more.) 2008-12-13 21:21:40 +00:00
Ilmari Karonen
2b796b766a Fix interwiki link regression from r44524. 2008-12-13 21:14:50 +00:00
Ilmari Karonen
7f71d9e38f followup to r44520: simplify various bits by removing checks now made redundant 2008-12-13 04:14:40 +00:00
Ilmari Karonen
34fb6297cd Step 2 in NS_IMAGE -> NS_FILE transition (bug 44) (WARNING: huge commit).
This is a global search and replace of NS_IMAGE and NS_IMAGE_TALK with NS_FILE and NS_FILE_TALK respectively in all core files, excluding those already updated in step 1 (r44004).
2008-12-01 17:14:30 +00:00
Steve Sanbeg
5ec8bddd10 undo 43772; there seems to be various special behavior hacked onto <div>, some of which may be intentional 2008-11-20 23:55:38 +00:00
Steve Sanbeg
6c54601676 this should prevent the parser from inserting <p> tags around the second line of divs 2008-11-20 20:50:12 +00:00
Chad Horohoe
d8119bd420 Revert r41710, r41978, r42012, r42048 (integration of Poem extension to core plus misc. fixes). Per Wikitech-l, this isn't properly attributed to the original authors of the extension. Furthermore, "Poem" is entirely too narrow a name for the functionality this tag provides. If this is to be integrated, a better name should be chosen. 2008-11-15 01:19:46 +00:00
Raimond Spekking
c34f717965 Add messages for hardcoded parser warnings 2008-11-12 21:00:59 +00:00
Ilmari Karonen
a3fbf7fc49 Emit a warning message if a single page has multiple conflicting {{DEFAULTSORT:}} keys.
(Also, replace wfMsg() with wfMsgForContent() for the unknown_extension_tag message.)
2008-11-02 14:21:04 +00:00
Fran Rogers
7c1712c550 Convert literal tabs to &#9; when passing them through Tidy, to prevent them from being clobbered. 2008-10-20 06:46:09 +00:00
Nicolas Dumazet
6198592553 (bug 13701) {{NUMBEROFVIEWS}} magic word to show number of total views. 2008-10-19 04:11:02 +00:00
Brion Vibber
5ad630fca0 Fix for r41837 -- apply HTML stripping to explicit alt text as well as implicit.
Added parser test cases to confirm.
2008-10-15 21:20:13 +00:00
Brion Vibber
2b8a8b2624 Pulling out r42105 for now -- "Added 2 hooks. One in Parser to allow custom handling of namespace links, and one in EditPage, to allow custom output/handling when a user has no edit rights"
The namespace parsing thing feels very hacky and grabs bits out of an internal implementation function which doesn't feel like a stable interface.
Would recommend thinking about this and coming up with a more serious stable interface for it.
2008-10-15 20:57:02 +00:00
Jason Richey
a719d5ff1c Added 2 hooks. One in Parser to allow custom handling of namespace links, and one in EditPage, to allow custom output/handling when a user has no edit rights 2008-10-15 19:32:59 +00:00
Brion Vibber
88786f760f Cleanup for r41952: > is usually easier to understand than !<= :) 2008-10-13 02:38:31 +00:00
Ryan Schmidt
4f655ca3ba * re-implement r41983 (forgot to add log message). Changes made:
** <poem> handling fixes: use DoubleReplacer class instead of create_function(), moving recursiveTagParse above line-break replacements, removed strip items, updated parser tests to reflect new output when combined with <nowiki>
2008-10-13 02:18:49 +00:00
Brion Vibber
65ed1fd91b Revert mystery change r41983 -- no explanation of the change or its purpose.
Appears to be an attempt to remove some extra whitespace, but it's kind of unclear.
2008-10-12 23:14:39 +00:00
Ryan Schmidt
2595b8fd25 2008-10-12 02:20:08 +00:00
Ryan Schmidt
f9a901e6a5 * fixes for the merged Poem extension, per comments by Tim Starling on CodeReview (r41710)
* adding <poem> tests to the parser tests file
2008-10-11 21:53:44 +00:00
Alex Z
e6a33f0c81 Adding file cache to the parser to improve rendering time on pages with several uses of the same image; designed with input from Brion and Tim. Cache size is limited to 1000. 2008-10-10 22:19:55 +00:00
Aryeh Gregor
bc65c6bb12 (bug 368) Allow alt= attribute for images
Alt text is now set in the following ways, in decreasing priority:

1) Set to the alt= parameter if present.
2) Set to the unnamed (caption) parameter if present, and if the image does not have the thumb or frame option set (i.e., if the unnamed parameter is not actually being used for a caption -- using it as both caption and alt text would just lead to text being repeated).
3) Set to the empty string.

Title text and captions should not be affected in any case.  The only backward-compatibility effect (i.e., on images not using the new alt= syntax) should be that if previously the same text was repeated in the alt text and then again in the caption, the alt text will now be empty.  Setting the alt parameter should never change the HTML output compared to not setting it, except of course changing the alt text.

All parser tests pass, except the usual ones.
2008-10-08 16:33:36 +00:00
Brion Vibber
86055bdfa4 Update to r41727 (bug 539) "click" parameter on images.
* Renamed to "link", which seems clearer and less mouse-centric ;)
* Added parser test cases:
   3 new PASSING test(s) :)
      * Image with link parameter, wiki target  [Has never failed]
      * Image with link parameter, URL target  [Has never failed]
      * Image with empty link parameter  [Has never failed]
2008-10-07 00:31:26 +00:00
Tim Starling
77d634b922 * Added "click" parameter to image links, to allow images to link to an arbitrary title or URL. This should replace inaccessible and incomplete solutions such as CSS-based overlays and ImageMap. 2008-10-06 05:55:27 +00:00
Tim Starling
0d322a394e * Allow $wgDiff3=false
* Don't call quickUserCan('edit') unless section edit is enabled
* In DatabasePostgres and DatabaseSqlite: throw an exception on connection error
* In DatabasePostgres: don't send an invalid connection string whenever one of the fields is empty. Use quoting.
* In Database: make the captured PHP error prettier
* Display a descriptive error message when the user navigates to index.php with PHP 4, not a parse error. Check to see if the *.php5 extension works, using file_get_contents().
* The default port number for PostgreSQL is 5432, not blank.
* Better default for $wgDBname
2008-10-06 00:45:18 +00:00
Ryan Schmidt
8f521476a8 * integrate Poem extension into core (patch by Nathaniel Herman) 2008-10-05 20:27:23 +00:00
Tim Starling
110c0bb72f Revert revert r41406 of r41333, and removed one space between attributes. 2008-09-30 01:00:40 +00:00
Brion Vibber
b74cc54810 Revert r41364 -- broke 22 parser test cases with change of alt behavior.
The caption was originally defined *as* the alt text (defaulting to the image file name if there is no alt text). Note that a separate caption text is only displayed in some display modes ('frame' and 'thumb', iirc), and not by default.

Please run the parser tests and check the effect you have on them. If it's really an appropriate change, then update the test cases. If you're not sure, consider backing out pending further discussion. :)

It might be appropriate to not set the 'alt' attribute for frame/thumb cases, but definitely not for inline images where we already have a way of setting the alt text which you're removing!
2008-09-30 00:21:59 +00:00
Brion Vibber
0dd22a5406 Back out r41333 -- causes lots of parser test regressions due to funny spacing. Probably an easy fix but it wasn't tested apparently. :) 2008-09-30 00:14:25 +00:00
Aryeh Gregor
a53fa1decd (bug 368) Allow alt= attribute for images
If the attribute is not specified, default to empty string, not repeating the caption.
2008-09-28 21:07:34 +00:00
Alexandre Emsenhuber
83cab059b3 Use $wgContLang here, this should not vary with the user language. 2008-09-28 10:51:58 +00:00
Niklas Laxström
7928acbcd4 * (bug 15196) Free external links should be numbered in a localised manner 2008-09-28 08:45:03 +00:00
Tim Starling
cdfdb50943 * Added the ability to set the target attribute on external links with $wgExternalLinkTarget
* Removed the namespace parameter from Linker::makeExternalLink(), added a generic associative array of attributes instead. Let the Parser decide whether to use rel=nofollow.
2008-09-28 02:35:37 +00:00
Chad Horohoe
8b9e04434f Call Xml class directly, rather than the global function. 2008-09-22 17:01:44 +00:00
Niklas Laxström
78f44d3447 * $name is not defined here 2008-09-21 07:18:24 +00:00
Tim Starling
93a66a41aa Revert r40712, replace_variables is correct. 2008-09-15 06:37:57 +00:00
Chad Horohoe
793526a920 Revert r40707. Could produce broken XHTML if the source wiki has unclosed div tags. 2008-09-10 23:02:48 +00:00
Alexandre Emsenhuber
5193105e5c (bug 15555) misspelled replace_variables() function in doc of Parser::preprocessToDom(), changed to replaceVariables() 2008-09-10 19:31:01 +00:00
Chad Horohoe
128d51a4fe (bug 12400) Add class to content transcluded from IW source. 2008-09-10 18:18:26 +00:00