Notifications menu shows raw backslash escapes in titles

This is quite minor, at least in the situation I saw it in.


  • The notifications menu looks like it shows raw topic titles, without applying the backslash escaping rules. Compare left and right red boxes:


  • Here’s what the raw thread title looks like:


  • And how the title is rendered when viewing the topic itself:


All look correct to me except for the notification menu.

(We also surely have proof that time travel will never exist, as nobody has gone back in time and stopped MS-DOS / Windows from using a common escape character all over file paths and leaking into conversations about file paths. :smiley: )

4 Likes

I don’t think this is worth fixing.

There is no need to escape \ in titles, this is subtle bug in our title prettier.

Just make your title ..folder Using "\"; Says... no need to escape stuff.

FWIW, there are some cases where you do need to escape baskslashes in titles.

One example is a title about UNC paths in Windows:


Problem going to \\server\share

becomes:

Problem going to \server\share

unless you double up the first pair of backslashes:

Problem going to \\\\server\share


Our forum is about a file manager, so this example isn’t entirely contrived. That said, it is still rare for it to matter, and the problem is still small and cosmetic, so it may still not be worth fixing. We can certainly live with it.

I think that is a bug then … our pretifier has to stop this backslash escaping.

It is completely non-obvious that you should need to escape in the title.

2 Likes

I see… was reading through the code, will leave it for @codinghorror to decide.

The reason this happens is due to:

https://github.com/discourse/discourse/blob/5dbd6a304bed5400be481d71061d3e3ebb4d6785/lib/html_prettify.rb#L179-L194

Should I remove this magic?

Or maybe our topic titles should be passed through the prettfier prior to being sent as notifications. Not sure.

If the escaping is kept in titles, one thing that is a little odd is that the rules aren’t the same as in message bodies.

For example, C:\* requires you double the backslash in a message body, but not in a title.

(I guess it makes sense in a way: Bold and italic markdown don’t apply to titles, * has no special meaning at the end of words in titles, so it doesn’t need escaping. OTOH, it’s easier to remember either one set of rules, or that escaping isn’t needed at all for titles. Still, it’s minor in the grand scheme of things so whatever you choose to do, if anything, is fine. Always a risk that changing something breaks something else!)

That only applies to titles? Why is that even there?

That code only apply to title prettify, we lifted it from the original implementation. Happy to remove it if you are comfortable with there being no easy way to specify " in a title (as opposed to the pretiffied version)

Yeah I suggest removing it then

There is still the edge case that quotes are not all “fancy” in notifications, we should probably make it consistent some day.

But, agree, that fancy escaping is just confusing for most people.

3 Likes

This specific issue is fixed by:

https://github.com/discourse/discourse/commit/82ca0e368e8758b463c0c589f649f9bb73fc2d79

5 Likes