brendanheywood / moodle-local_cleanurls

Lets drag Moodle's url structure into this century...
37 stars 24 forks source link

Invalid characters in clean urls #40

Closed roperto closed 7 years ago

roperto commented 7 years ago

Issued raised by @nhoobin

Assignment Stage 2 (ASS#2) The shortname is 'ASS#2'.

Example page with the issue. https://moodle/course/ABC123/assign/456-ass#2

Scroll down to and click on 'View all Submissions' in the administration navigation bar. https://moodle/course/ABC123/assign/456-ass#2?action=grading

Nothing happens as the url thinks it is an anchor link.

The cleanurls plugin should only allow alphanumeric, -, and _ characters. Characters with accents should be allowed too.

brendanheywood commented 7 years ago

We should probably flog some battle tested code from another project, a good candidate is sanitize_title_with_dashes() from wordpress:

https://github.com/WordPress/WordPress/blob/c2d709e9d6cbe7f9b3c37da0a7c9aae788158124/wp-includes/formatting.php#L1959

Not sure about pulling in the utf8 stuff, we can cross that bridge later as needed. Add a comment with attribution back to the wordpress source / function

roperto commented 7 years ago

Done, but I had to import a few extra functions together.