MediaWiki talk:Gadget-AuthorityControl.js

From Wikidata
Jump to navigation Jump to search
On this page, old discussions are archived after 730 days. An overview of all archives can be found at this page's archive index. The current archive is located at MediaWiki talk:Gadget-AuthorityControl.js/Archive/2020.


SMILES (Property:P233 and Property:P2017) values need to be UrlEncoded[edit]

I think this gadget is responsible for adding links to canonical SMILES (P233) and isomeric SMILES (P2017) values. Unfortunately, SMILES uses symbols that can break URL (/, #). Is it possible to make values of these two properties UrlEncoded?

  • this is what the link look like now: http://www.simolecule.com/cdkdepict/depict/bow/svg?smi=CO[C@@H]1C[C@H](C[C@@H](C)[C@@H]2CC(=O)[C@H](C)\C=C(C)\[C@@H](O)[C@@H](OC)C(=O)[C@H](C)C[C@H](C)\C=C\C=C\C=C(C)\[C@H](C[C@@H]3CC[C@@H](C)[C@@](O)(O3)C(=O)C(=O)N4CCCC[C@H]4C(=O)O2)OC)CC[C@H]1O&zoom=2.0&annotate=cip (from Q32089#P2017)
  • and it should be like this to work properly: [1].

Wostr (talk) 21:35, 18 November 2019 (UTC)[reply]

Update to FAA URL[edit]

{{Edit request}} Good day. The FAA URL on line 90 needs to be updated to https://registry.faa.gov/AircraftInquiry/Search/NNumberResult?nNumberTxt=$1. The CAA link on line 92 is also non-functional; the search page is at https://www.caa.co.uk/aircraft-register/g-info/search-g-info/, but I do not know how to format the URL for its search function. Thanks! Huntster (t @ c) 22:09, 9 January 2023 (UTC)[reply]

✓ Done --Matěj Suchánek (talk) 18:11, 10 January 2023 (UTC)[reply]

Requesting 2 changes[edit]

{{Edit request}}

Requesting 2 changes in makeLink, first one to prevent double escape for slashes in regexps (very common):

	if ( linkTemplate === 'https://regex101.com/?regex=$1' ) {
		// Escape the character used as the delimiter, which for
		// regex101.com is slashes.
		// URL encode the value to avoid problems when a regex contains
		// characters with a special meaning in URLs, like & and #.

		try {
			// try to encode / as \/, if not encoded yet
			linkValue = (new RegExp(linkValue)).source;
		} catch (error) {
			// display anyway
		}
		linkValue = encodeURIComponent( linkValue );
	}

Second change again in makeLink, fixing XSS. Exactly the same as https://phabricator.wikimedia.org/T297570, but on gadget level for string datatype (example). Ping @Addshore: @Lucas Werkmeister::

	var link = linkTemplate.replace( /\$1/g, linkValue );

	try {
		// Disallow javascript links to prevent xss.
		// Use URL parser to handle cases with spaces and other bypasses
		if ((new URL(link)).protocol === 'javascript:') {
		    return $( '<span>' ).text( displayText )
		}
	} catch (error) {
		return $( '<span>' ).text( displayText );
	}
	
	return $( '<a>' )
		.text( displayText )
		.attr( 'href', link )
		// Show the 'external link' icon:
		.addClass( 'external' );

Comparing to T297570, this allows arbitrary protocols like data:, skype:, email: - I think it is useful. Lockal (talk) 06:02, 10 January 2023 (UTC)[reply]

@Zabe, for the first part I meant to edit existing block, not to add a new one, see https://phab.wmfusercontent.org/file/data/yh5txol6hsirbfk2xpmb/PHID-FILE-g2qfmylemavc7yds3ljg/image.png . It double-encodes now in Property:P4175#P4175$E7B80553-A37E-4A29-978D-702E6FB87364. Lockal (talk) 08:47, 1 February 2023 (UTC)[reply]
Upd: done as a part of https://phabricator.wikimedia.org/T328399, closing. I also created https://github.com/firasdib/Regex101/issues/1980 to provide a better fix from regex101 side, if possible. --Lockal (talk) 06:44, 17 February 2023 (UTC)[reply]

Premiership rugby[edit]

Hello, the formatting URL for the Premiership rugby has changed.

The new one is: https://www.premiershiprugby.com/player?PlayGuid=$1

See here as example. Regards. -- Blackcat 21:20, 7 May 2023 (UTC)[reply]

You need to report that on the talk page if the property. Mbch331 (talk) 08:21, 8 May 2023 (UTC)[reply]
@Mbch331: thanks, I'll do. Can I kindly ask you to ping me next time though? -- Blackcat 21:13, 8 May 2023 (UTC)[reply]