Page MenuHomePhabricator

Error: URL hostname is not whitelisted: wikiraw:///Fertility-csv
Open, Needs TriagePublic

Description

I run a test wiki at http://tools.wikimedia.pl/~saper/b/index.php running:

I have copied https://www.mediawiki.org/wiki/Extension:Graph/Demo/HistoricalFertilityRates example to the wiki and adjusted data source paths to wikiraw:///Fertility-csv and wikiraw:///WorldMap-iso3-json respectively.
Both data files have been copied from the mediawiki.org to the respective shortened names http://tools.wikimedia.pl/~saper/b/index.php?title=Fertility-csv and http://tools.wikimedia.pl/~saper/b/index.php?title=WorldMap-iso3-json

However, I keep getting "Error: URL hostname is not whitelisted: wikiraw:///Fertility-csv" on the console.

Setting

$wgGraphAllowedDomains = [ 'wikiraw' => [ 'tools.wikimedia.pl' ] ];
wfLoadExtension( "Graph" );

does not seem to help.

When I have added

$wgGraphAllowedDomains = [ 'wikiraw' => [ 'tools.wikimedia.pl' ], 'http' => [ 'tools.wikimedia.pl' ] ];

I started getting XHR error, since it tried getting

http://tools.wikimedia.pl/w/api.php?format=json&formatversion=2&action=query&prop=revisions&rvprop=content&titles=Fertility-csv

(my wiki lives in a subdirectory).

What is a proper way to whitelist 'wikiraw' pseudo-protocol?

How can run the wiki in a subdirectory and still use the wikiraw protocol?

Event Timeline

saper created this task.Sep 17 2016, 11:37 PM
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptSep 17 2016, 11:37 PM
Yurik added a subscriber: Yurik.EditedSep 18 2016, 2:49 AM

@saper, this is the correct way to configure it:

$wgGraphAllowedDomains = [ 'wikiraw' => [ 'tools.wikimedia.pl' ], 'http' => [ 'tools.wikimedia.pl' ] ];

What do you mean by "my wiki lives in a subdirectory"?
I see you have http://tools.wikimedia.pl/~saper/b/api.php as the endpoint. Sadly, at this point the Graph extension is hardcoded to use /w/api.php. The quick hack is to change graph2.compiled.js file line 432 to use your api endpoint. Eventually, I should make it possible to configure non-default api endpoint in the settings.

@Yurik thank you very much, I forgot to add my workaround here: https://github.com/saper/mediawiki-extensions-Graph/commit/7985fd39623b345f9a446a8a59ecef240a748f97

One thing which wondered me when trying "wikiraw:" protocol is that internal MediaWiki functions are not used in case of "this" wiki. This way any strange MediaWiki configuration could be easily supported. What about T145977 to change this?

Also it was pretty confusing to need to add "http" in the configuration next to the "wikiraw" protocol. Technically this makes sense, since we go via http API, but maybe after T145977 we would need to.

saper added a comment.EditedSep 18 2016, 6:40 PM

One more thing, the documentation at the extension page listed some probably obsolete variables, which I have removed. Is this okay?

@saper see my explanation why the protocols were designed this way in T145977#2647013. Of course suggestions on how to make it better are welcome :) The documentation definitely need some love, and I will be very grateful for your help :)