ProfessionalWiki / WikibaseRDF

Wikibase extension that allows defining RDF mappings for Wikibase Entities
https://rdf.wikibase.wiki
GNU General Public License v2.0
14 stars 4 forks source link

Add URL validation #96

Closed malberts closed 2 years ago

malberts commented 2 years ago

Refs #95

UI: Screenshot_20220914_215411

API:

curl -X POST -H 'Content-Type: application/json' "http://localhost:8484/rest.php/wikibase-rdf/v0/mappings/Q1"   -d '[{"predicate": "owl:sameAs", "object": "http://www.w3.org/2000/01/rdf-schema#subClassOf"}, {"predicate": "rdfs:subClassOf", "object": "foo:Bar"}]'

Screenshot_20220914_215559

malberts commented 2 years ago

WIP beacause we need to confirm the limitation of using filter_var( $object, FILTER_VALIDATE_URL ). https://www.php.net/manual/en/filter.filters.validate.php

Validates value as URL (according to » http://www.faqs.org/rfcs/rfc2396), optionally with required components. Beware a valid URL may not specify the HTTP protocol http:// so further validation may be required to determine the URL uses an expected protocol, e.g. ssh:// or mailto:. Note that the function will only find ASCII URLs to be valid; internationalized domain names (containing non-ASCII characters) will fail.

JeroenDeDauw commented 2 years ago

In practice this might already be good enough. Not catching some obscure stuff is already much better than letting in random junk.

JeroenDeDauw commented 2 years ago

But yeah, good to double-check with the stakeholders what they want exactly.

Perhaps using the same validation as Wikibase has for its URL data type makes sense. https://github.com/wikimedia/Wikibase/blob/master/repo/WikibaseRepo.datatypes.php#L342-L348

malberts commented 2 years ago

This should be good enough now by using Wikibase URL validation.

Screenshot_20220915_190140