Menu

#605 colons and project URIs

workingwiki
open
None
5
2014-09-23
2014-09-22
Lee Worden
No

I'm trying to use inter-wiki project prerequisite feature to display file http://lalashan.mcmaster.ca/theobio/worden/index.php/File:WW-PE.svg in a page on the projects wiki. It's giving me unpleasant error messages. I believe the problem has to do with processing of colons in project names and project URIs.

If I write <project-file filename="WW-PE.svg" project="pe-ww:http://lalashan.mcmaster.ca/theobio/worden:File:WW-PE.svg"/>, it fails to get the file because it's looking for a project called WW-PE.svg on a wiki called theobio/worden:File. This is the correct behavior but the wrong outcome. The semantics of project URIs is protocol:wiki URL:project name, where the wiki URL may contain any number of colons, and consequently the project name can't contain any.

Therefore any colons in the project name have to be URL-encoded. This is a necessary part of the URI semantics. But if I rewrite it as <project-file filename="WW-PE.svg" project="pe-ww:http://lalashan.mcmaster.ca/theobio/worden:File%3AWW-PE.svg"/>, I get:

Error: Invalid project name 'pe-ww:http://lalashan.mcmaster.ca/theobio/worden:File%3AWW-PE.svg'.

It's not handling URL-encoded colons in the project name correctly. This is a significant bug in the project-URI implementation. (Though it can be worked around by creating another project with no colons in its short name.)

Related

Bugs: #606

Discussion

  • Lee Worden

    Lee Worden - 2014-09-22

    This invalid project name message is coming from ProjectDescription::make_project_title(), which tries and fails to create a MediaWiki Title object representing the name of the project. This is a nice technique in general, delegating to the Title class the task of making sure the project has a reasonable name, but it's not working in this case. For some reason, Title is rejecting the combination of colons and %3A.

    I could url-decode the string before giving it to Title for validation, but not with the current code, I'm pretty sure, because the Title object is used for the project title. We'd have a project URI with too many colons, and the benefit of URL-encoding would be lost.

    I should see why and how Title is rejecting this string, to make sure I'm not missing anything, but barring weird surprises I think the upshot is that I can use Title to validate project strings, with proper precautions for URL encoding, but I can't use it to represent them.

     
  • Lee Worden

    Lee Worden - 2014-09-22

    Yes, according to https://www.mediawiki.org/wiki/Manual:Title.php#Article_name percent signs are not allowed in article names represented by the Title class. They are allowed in URLs for MediaWiki pages, but percent-encoding (URL encoding) has to be decoded for use internally. Therefore I can use Title to validate project names including URIs (if I think that's a good way to validate), but I can't use Title objects to store project URIs for internal use because I need to retain percent-encoded colons in URIs.

     
  • Lee Worden

    Lee Worden - 2014-09-23

    make_page_title() is only used within WWStorage.php, and always followed by converting the title back into a string. So this problem can be fixed.

    I have an unrelated thing that needs me to decouple this from Title, so I think I'll replace the use of Title by a direct check for valid characters. Need it to be compatible with Title's requirements though, since projects need to be able to have ProjectDescription: pages. It should be okay to use a urldecode() when making the ProjectDescription: page title though, I hope?

    I guess the check will be:

    • if urldecode( $name ) contains only the characters allowed by Title

    and make sure to do a urldecode before trying to go to ProjectDescription:.

     

Anonymous
Anonymous

Add attachments
Cancel





Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.