Page MenuHomePhabricator

mw.Uri cannot be called on subpages (TypeError: Cannot read property 'protocol' of undefined)
Closed, DuplicatePublic


On a JS error occurs.*/logstash-2021.02.24?id=xp8k1ncBg_6mGHGhXBpB

Not sure if this is a VE error or a mediawiki.Uri error.

mw.config.get( 'wgRelevantPageName' )
mw.util.getUrl( mw.config.get( 'wgRelevantPageName' ) )
new mw.Uri( mw.util.getUrl( mw.config.get( 'wgRelevantPageName' ) ) )
TypeError: Cannot read property 'protocol' of undefined

The code in question is:

conf = mw.config.get( 'wgVisualEditorConfig' );
	tabMessages = conf.tabMessages;
	viewUri = new mw.Uri( mw.util.getUrl( mw.config.get( 'wgRelevantPageName' ) ) ); // <<< problematic line
	try {
		uri = new mw.Uri( null, { arrayParams: true } );
	} catch ( e ) {
		// URI failed to parse, probably because of query string parameters. (T270331)
		// Fall back to the viewUri so that initialization completes.
		// Ideally mw.Uri would ignore invalid parameters or characters.
		uri = viewUri;

Event Timeline

This has nothing to do with subpages, or with VisualEditor. mw.Uri crashes when there's an un-encoded '%' character in the URL. This is the exact same issue as T269948 or T268060. It should be tracked and fixed as a bug in mw.Uri, not in a hundred random extensions that use that code.