[Page move] Do not allow "/" as the last character for the destination

RESOLVED FIXED

Status

Mozilla Developer Network
General
--
minor
RESOLVED FIXED
3 years ago
3 years ago

People

(Reporter: fscholz, Unassigned)

Tracking

Details

(Whiteboard: [specification][type:bug])

(Reporter)

Description

3 years ago
What did you do?
================
1. Moved https://developer.mozilla.org/en-US/docs/nsLocalFile to https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Reference/Components/

What happened?
==============
I was too quick and the URL https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Reference/Components/ is wrong.

The document is now inaccessible as the trailing slash gets removed by Firefox and I only get to see
https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Reference/Components

What should have happened?
==========================
I should have been less quick and moved the page to https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Reference/Components/nsLocalFile

However, the wrong slug was not caught either. Probably should have been.

So, do not perform page moves, if the last character in the destination URL is a slash "/".

Is there anything else we should know?
======================================
Please move the inaccessible doc to the right location, too.

I will be less quick next time.
(Reporter)

Comment 1

3 years ago
The document is https://developer.mozilla.org/admin/wiki/document/10791/
:groovecoder, can you help restore the page? Fixing the trailing slash bug is a minor priority, but we've lost some content.
Severity: normal → minor
Flags: needinfo?(lcrouch)
I'm confused ... the title of https://developer.mozilla.org/admin/wiki/document/10791/ is "nsDirectoryService" ? That doesn't seem like it should be the nsLocalFile article?
Flags: needinfo?(lcrouch) → needinfo?(fscholz)
(Reporter)

Comment 4

3 years ago
Yes, and that title is correct.

The slug is wrong:
It is:         [1] Mozilla/Tech/XPCOM/Reference/Components/
but should be: [2] Mozilla/Tech/XPCOM/Reference/Components/nsLocalFile

The parent page is also correct, it is without a slash at the end:
               [3] Mozilla/Tech/XPCOM/Reference/Components

Currently, [1] redirects to [3], but they are actually two document. That is why the slug [1] needs to become slug [2] (and that is what I intended to do but did wrongly).
Flags: needinfo?(fscholz)
Something else strange has happened ... 

d = Document.objects.get(slug='Mozilla/Tech/XPCOM/Reference/Components/', locale='en-US')
d2 = Document.objects.get(slug='Mozilla/Tech/XPCOM/Reference/Components/nsLocalFile', locale='en-US')

In [16]: d.slug
Out[16]: 'Mozilla/Tech/XPCOM/Reference/Components/nsLocalFile'

In [17]: d2.slug
Out[17]: u'Mozilla/Tech/XPCOM/Reference/Components/nsLocalFile'

So there's still an 'nsLocaleFile' in the database, and it won't let me move Components/ into it. Furthermore, https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Reference/Components/nsLocalFile is still accessible. So what is triggering requests to Components/ ? If nothing, I can delete the erroneous Components/ doc.
(Reporter)

Comment 6

3 years ago
Argh, sorry.

'nsDirectoryService' is the one not nsLocalFile.

Although in/out [16] is still weird.

https://developer.mozilla.org/admin/wiki/document/10791/ says:
/en-US/docs/Mozilla/Tech/XPCOM/Reference/Components/ (nsDirectoryService)

Which I interpret as: 
/slug/ (title)
Updated:

In [1]: from kuma.wiki.models import Document

In [2]: nsDirectoryService = Document.objects.get(slug='Mozilla/Tech/XPCOM/Reference/Components/', locale='en-US')

In [3]: nsDirectoryService.slug
Out[3]: u'Mozilla/Tech/XPCOM/Reference/Components/'

In [4]: nsDirectoryService.slug = u'Mozilla/Tech/XPCOM/Reference/Components/nsDirectoryService'

In [5]: nsDirectoryService.save()

https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Reference/Components/nsDirectoryService is now reachable. 

https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Reference/Components/ seems to correctly redirect to https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Reference/Components though it doesn't seem to be correctly finding/showing the link to nsDirectoryService ?
(Reporter)

Comment 8

3 years ago
The restoring of the document was successful. Thanks!

Leaving this open to fix the actual problem of having the last character in the destination URL being a slash "/". We should not allow it.
I've submitted a PR that fixes this issue by removing the trailing slash if one is present in the slug: https://github.com/mozilla/kuma/pull/3176

Comment 10

3 years ago
Commits pushed to master at https://github.com/mozilla/kuma

https://github.com/mozilla/kuma/commit/62f969077693482bbe85411c93dcb25095156e42
fix bug 1145580
Added check for trailing slash and a test for this fix.

https://github.com/mozilla/kuma/commit/53df412ecabdb54bd966cd75f8236a47168f924e
fix bug 1145580 - add info about what the slug rules are
when moving pages.

https://github.com/mozilla/kuma/commit/bbae237b0bd0591f313035ce2395f916a8970fc7
bug 1145580 - Update display of instructions list

Updated

3 years ago
Status: NEW → RESOLVED
Last Resolved: 3 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.