Page MenuHomePhabricator

Investigate using simple grep to check js for raw html messages
Closed, DeclinedPublic

Description

While looking for raw html messages (for T200997), I came up with a grep:

for i in `find . -name '*.js' -type f`
	do if tr $'\n'$'\t' ' ' < "$i" | grep -o -e '[^ ]*\.html(\s*\(mw\.msg\s*([^()]*\([^()]*([^()]*)[^()]*\)*)*\|mw\.[mM]essage\s*([^()]*\([^()]*([^()]*)[^()]*\)*)\s*\.\s*\(params(\([^()]*([^()]*)[^()]*\)*)\.\)*\(plain\|text\)\s*(\s*)\)\s*)*'
	then echo $'\t'--^ Raw html message in file "$i";fi;
done

While this will obviously miss a lot, it seems to have an extremely low false positive rate. Maybe it is worth adding to CI as a quick and dirty check.

Event Timeline

OK, I guess we can do this pretty trivially. Long-term is it possible to implement this with eslint or something?

Declining this as I think it is likely a relic of the past. We still have the the mediawiki-i18n-check-docker running for twn messages, phan-taint-check running under phan for most php repos (which can find problematic message usage like this), bugs like T200997 seemingly mostly resolved and still-active efforts like T2212.