Automatic encoding of parsed URL params

If you want to try my patch above, you can force apply it from your app.yml file. At the very end:

## Any custom commands to run after building
run:
  - exec: echo "Beginning of custom commands"
  - exec: if grep -q 'uri.encoding == US_ASCII' $home/vendor/bundle/ruby/2.3.0/gems/actionpack-4.2.9/lib/action_dispatch/journey/router/utils.rb ; then curl https://meta.discourse.org/raw/67232/17 | patch -p0 -u -d $home ; fi ; true

The “Beginning of custom commands” is already in the standard app.yml, the change is the long line right after that. What it does:

if grep -q 'uri.encoding == US_ASCII' ... then :arrow_right: if the patch hasn’t been applied

curl https://meta.discourse.org/raw/67232/17 :arrow_right: then download the raw post with the patch

patch -p0 -u -d $home :arrow_right: apply the patch (patch is smart enough to ignore the “garbage” post text)

fi; true :arrow_right: always return true so Pups will be happy

But note that this is not a Discourse approved patch and hasn’t seen a whole lot of testing. It works for me, but who am I?

(I submitted it to Rails, and it was rejected because this is fixed in another way in Rails 5. But Discourse is still on Rails 4.)

4 Likes

@blake might have already let the team know, but we’re definitely impacted by this one (and we’re paying customers). It’s an issue for our users (biggest concern) and for the old search bots (much smaller concern). Any thoughts on timing/priority for the Discourse team? :slight_smile:

3 Likes

Unfortunately this looks like an upstream bug in Ruby / Rails so it is not easy to fix.

We should at least escalate it to the appropriate Ruby/Rails tracker.

Looks like they rejected it:

(I submitted it to Rails, and it was rejected because this is fixed in another way in Rails 5. But Discourse is still on Rails 4.)

1 Like

Specifically here: https://github.com/rails/rails/pull/30119#issuecomment-320957733 (link goes to a particular comment). It could be that’s me just going about submitting fixes in the wrong way.

4 Likes

It looks like this is fixed in Rails 5 but it is unclear when we can move Discourse to that (we are currently on Rails 4). There are typically a lot of performance regressions in each new release of Rails that we have to help fix, so it takes some time for us to move.

1 Like

Well, time for a custom before_filter, I guess.

1 Like

Now that Discourse is on Rails 5, is it safe to reactivate the slug generation to encoded?

2 Likes

I guess so, based on this reply:

but is there any benefit to change the slug generation method? for example for SEO or …?

It’s for SEO and for human consumption. Our community heavily uses Japanese.

2 Likes

Yes, apologies for the delay but it should be 100% working now! Let us know if you run into any issues.

6 Likes

when the slug generation method is changed to “encoding”, the spaces between each two words in the topic titles changes to - and it makes the topic list page very unclean.

is it something related to rails or is it solvable by changes to the forum?

It’s a bug that’s been fixed a few hours ago. Update to latest.

3 Likes

thanks, last night I’ve changed the slug generation method back to encoding and then used this method to refresh all the topic titles.

So all the titles in our forum has now lots of “-”; perhaps some bad timing for the change!

now that I check (after the update) the “-” won’t remove by simply updating titles.

is there any way to remove the “-” from the titles?

Edit them by pressing the edit button?

1 Like

that can work, but then I need to edit some thousands topics and remove “-” by hand.

perhaps uploading the backup and rewriting those topics and replies from last night is easier.

isn’t there any way to remove - from topics in rails console?

How do you have thousands of topics in one day?

1 Like

last night I updated all the topic titles so that the new encoding method applies to previous titles as well.

1 Like

I see, since it was @tgxworld’s bug maybe he can assist you.

3 Likes