DeArrow
DeArrow copied to clipboard
User-submitted titles containing linebreaks behave oddly
I recently found a video where there was an existing user-submitted title containing a linebreak. This title did print out a linebreak on the video page itself, but does not print it in places like the channel's /videos page. That's not the weird behaviour (it may be intentional?), just some context.
The weird behaviour started when I submitted a new title of my own, that, among some other minor changes, removed the seemingly-unintentional linebreak from the pre-existing submission. Upon hitting "Submit", the original user-submitted title without a linebreak replaced only the first line of the displayed video title.
It's a bit complicated, so here's an example:
Pre-existing user-submitted title:
Example video
title
New submission:
New example video title
Displayed video title updates to read:
Example video title
title
Unsurprisingly this oddity disappears after refreshing (returning to the same title with linebreak that was originally present, presumably as that remains the highest-voted title), but I suspect that this may have been how a linebreak was accidentally included and not immediately noticed and corrected by the submitter: it seems that the linebreak is only stripped when injecting into the DOM from clicking the "Submit" button, but not when sending to the server or when injecting from an initial page load, meaning that the title shown on submission would not match the title shown to subsequent viewers if a linebreak is included. It also seems that the process updating the UI doesn't expect there to be any linebreaks present, and can't replace any content contained after the first linebreak once one has been printed.