The max size of comments seems OK, but can we calculate it based on rendered character count, rather than input character count?
For example, this input:
This sentence has *emphasis* and a [link](https://en.wikipedia.org/wiki/Hyperlink).
Renders as:
This sentence has emphasis and a link.
which has an apparent size of 38 characters, but has 83 characters total input.
IMHO the intention of the comments size limit is to limit the apparent or rendered size. Adding links adds convenience and clarity to comments, and the author should not be penalized when decorating a comment with them.
The total input limit should probably be capped at say double the rendered char count to prevent malicious data entry.
If this is declined, please state the justification.
input.length
toinput.replace(/\*|\[([^\\]+)]\(.*?\)/g, '$1').length
in the browser and similarly terse code on the server.*
as not Markdown,_
, cases where the Markdown is invalid, convert all the magic links active for that site, etc. You have to test and verify that the two separate implementations (frontend and backend) produce the same results, etc. Once implemented, that doesn't resolve the UX issues, which are confusing as all get-out to users who don't understand the technicalities of what's being done. And still doesn't resolve the underlying issue of changing the comment size in the database.alter table comment alter column text nvarchar(1000)
. IMHO it's a mistake to limit it in the first place - there's no advantage doing that. Just usetext
as the type.