Page MenuHomePhabricator

Redirect handling of hash fragments is incorrect
Closed, InvalidPublic

Event Timeline

Anomie added a subscriber: Anomie.

The redirect in question is

The API is returning what MediaWiki returns:

hphpd> =Revision::newFromId( 272534 )->getContent()->getRedirectTarget()->getFragment()
=Revision::newFromId( 272534 )->getContent()->getRedirectTarget()->getFragment()
"Section %"

"Section %" is indeed the actual fragment in the wikitext, which is what the API returns here. Note the API also returns the target title as "User:BSitzmann (WMF)/MCS/Test/redirect test3 target" rather than something like "User%3ABSitzmann_%28WMF%29/MCS/Test/redirect_test3_target".

What it becomes when output in HTML or a URL depends on the wiki's configuration settings. In 1.30.0-wmf.12,

hphpd> =$wgExperimentalHtmlIds
hphpd> =Sanitizer::escapeId( 'Section %' );
=Sanitizer::escapeId( 'Section %' );
hphpd> $wgExperimentalHtmlIds = true
$wgExperimentalHtmlIds = true
hphpd> =Sanitizer::escapeId( 'Section %' );
=Sanitizer::escapeId( 'Section %' );

Or in master,

>>> $wgFragmentMode = [ 'legacy', 'html5' ];
=> [
>>> return Sanitizer::escapeIdForAttribute( 'Section %', Sanitizer::ID_PRIMARY );
=> "Section_.25"
>>> return Sanitizer::escapeIdForAttribute( 'Section %', Sanitizer::ID_FALLBACK );
=> "Section_%"

We could expose $wgFragmentMode from meta=siteinfo, but that's a matter for a different task.

Jdlrobson edited projects, added MediaWiki-General; removed MediaWiki-Action-API.

There's a bug here. Whether it's at the API or not is irrelevant and I'd appreciate it if we tracked it rather than marking it as invalid and pretending it to not exist. Stalled might be more appropriate here, if you feel like this is blocked on $wgExperimentalHtmlIds

We could expose $wgFragmentMode from meta=siteinfo, but that's a matter for a different task.

I really don't understand your logic here. This task tracks an issue. If you want to mark it with other projects or create another task for a related problem that will fix this feel free.

$wgExperimentalHtmlIds is effectively gone already since rMWfd6e9ef2d481: Human-readable section ID support, but we can't actually remove it until 1.31 thanks to the deprecation policy. Making T139744 a subtask is pointless.

There's a bug here.

The only "bug" here is that the API isn't returning the data in exactly the format that you want. I don't consider that a bug. Thus the close as invalid.

If you need $wgFragmentMode exposed in order to properly handle the data in the format in which it is being exposed, feel free to file a task requesting that. Or rewrite this task entirely if you'd really rather take that route, but I'd prefer a new task since that will make for a cleaner bug history.