Twig 3: Use verbatim instead of raw tag in templates

- also ensure we don't pass a null in one of the functions in
  functions.php
This commit is contained in:
towards-a-new-leftypol 2023-08-02 21:31:45 -04:00
parent a0450e49fe
commit d79a8ea78f
17 changed files with 63 additions and 59 deletions

View File

@ -2231,7 +2231,11 @@ function escape_markup_modifiers($string) {
}
function utf8tohtml($utf8) {
return htmlspecialchars($utf8, ENT_NOQUOTES, 'UTF-8');
if ($utf8 == null) {
return '';
} else {
return htmlspecialchars($utf8, ENT_NOQUOTES, 'UTF-8');
}
}
function ordutf8($string, &$offset) {

View File

@ -49,8 +49,8 @@
{% for footer in config.footer %}<p class="unimportant" style="text-align:center;">{{ footer }}</p>{% endfor %}
</footer>
</div>
<script type="text/javascript">{% raw %}
<script type="text/javascript">{% verbatim %}
ready();
{% endraw %}</script>
{% endverbatim %}</script>
</body>
</html>

View File

@ -112,9 +112,9 @@
</div>
<script type="text/javascript">{% raw %}
<script type="text/javascript">{% verbatim %}
ready();
{% endraw %}</script>
{% endverbatim %}</script>
</body>
</html>

View File

@ -1,4 +1,4 @@
{% raw %}
{% verbatim %}
/* gettext-compatible _ function, example of usage:
*
@ -109,16 +109,16 @@ function alert(a, do_confirm, confirm_ok_action, confirm_cancel_action) {
var saved = {};
var selectedstyle = '{% endraw %}{{ config.default_stylesheet.0|addslashes }}{% raw %}';
var selectedstyle = '{% endverbatim %}{{ config.default_stylesheet.0|addslashes }}{% verbatim %}';
var styles = [
{% endraw %}
{% for stylesheet in stylesheets %}{% raw %}['{% endraw %}{{ stylesheet.name|addslashes }}{% raw %}', '{% endraw %}{{ stylesheet.uri|addslashes }}{% raw %}'],
{% endraw %}{% endfor %}{% raw %}
{% endverbatim %}
{% for stylesheet in stylesheets %}{% verbatim %}['{% endverbatim %}{{ stylesheet.name|addslashes }}{% verbatim %}', '{% endverbatim %}{{ stylesheet.uri|addslashes }}{% verbatim %}'],
{% endverbatim %}{% endfor %}{% verbatim %}
];
var codestyles = {
{% endraw %}
{% for stylesheet in code_stylesheets %}{% raw %}'{% endraw %}{{ stylesheet.name|addslashes }}{% raw %}' : '{% endraw %}{{ stylesheet.uri|addslashes }}{% raw %}',
{% endraw %}{% endfor %}{% raw %}
{% endverbatim %}
{% for stylesheet in code_stylesheets %}{% verbatim %}'{% endverbatim %}{{ stylesheet.name|addslashes }}{% verbatim %}' : '{% endverbatim %}{{ stylesheet.uri|addslashes }}{% verbatim %}',
{% endverbatim %}{% endfor %}{% verbatim %}
};
if (typeof board_name === 'undefined') {
@ -126,16 +126,16 @@ if (typeof board_name === 'undefined') {
}
function changeStyle(styleName) {
{% endraw %}
{% if config.stylesheets_board %}{% raw %}
{% endverbatim %}
{% if config.stylesheets_board %}{% verbatim %}
if (board_name) {
stylesheet_choices[board_name] = styleName;
localStorage.board_stylesheets = JSON.stringify(stylesheet_choices);
}
{% endraw %}{% else %}
{% endverbatim %}{% else %}
localStorage.stylesheet = styleName;
{% endif %}
{% raw %}
{% verbatim %}
var styleUrl;
@ -178,9 +178,9 @@ function changeStyle(styleName) {
}
{% endraw %}
{% endverbatim %}
{% if config.stylesheets_board %}
{% raw %}
{% verbatim %}
if (!localStorage.board_stylesheets) {
localStorage.board_stylesheets = '{}';
@ -195,15 +195,15 @@ function changeStyle(styleName) {
}
}
}
{% endraw%}
{% endverbatim%}
{% else %}
{% raw %}
{% verbatim %}
if (localStorage.stylesheet) {
changeStyle(localStorage.stylesheet);
}
{% endraw %}
{% endverbatim %}
{% endif %}
{% raw %}
{% verbatim %}
function get_cookie(cookie_name) {
var results = document.cookie.match ( '(^|;) ?' + cookie_name + '=([^;]*)(;|$)');
@ -236,7 +236,7 @@ function highlightReply(id) {
function generatePassword() {
var pass = '';
var chars = '{% endraw %}{{ config.genpassword_chars }}{% raw %}';
var chars = '{% endverbatim %}{{ config.genpassword_chars }}{% verbatim %}';
for (var i = 0; i < 8; i++) {
var rnd = Math.floor(Math.random() * chars.length);
pass += chars.substring(rnd, rnd + 1);
@ -327,15 +327,15 @@ function rememberStuff() {
if (sessionStorage.body) {
var saved = JSON.parse(sessionStorage.body);
if (get_cookie('{% endraw %}{{ config.cookies.js }}{% raw %}')) {
if (get_cookie('{% endverbatim %}{{ config.cookies.js }}{% verbatim %}')) {
// Remove successful posts
var successful = JSON.parse(get_cookie('{% endraw %}{{ config.cookies.js }}{% raw %}'));
var successful = JSON.parse(get_cookie('{% endverbatim %}{{ config.cookies.js }}{% verbatim %}'));
for (var url in successful) {
saved[url] = null;
}
sessionStorage.body = JSON.stringify(saved);
document.cookie = '{% endraw %}{{ config.cookies.js }}{% raw %}={};expires=0;path=/;';
document.cookie = '{% endverbatim %}{{ config.cookies.js }}{% verbatim %}={};expires=0;path=/;';
}
if (saved[document.location]) {
document.forms.post.body.value = saved[document.location];
@ -361,13 +361,13 @@ var script_settings = function(script_name) {
};
function init() {
{% endraw %}
{% endverbatim %}
{% if config.allow_delete %}
if (document.forms.postcontrols) {
document.forms.postcontrols.password.value = localStorage.password;
}
{% endif %}
{% raw %}
{% verbatim %}
if (window.location.hash.indexOf('q') != 1 && window.location.hash.substring(1))
highlightReply(window.location.hash.substring(1));
@ -388,16 +388,16 @@ function ready() {
}
}
{% endraw %}
{% endverbatim %}
var post_date = "{{ config.post_date }}";
var max_images = {{ config.max_images }};
onready(init);
{% if config.google_analytics %}{% raw %}
{% if config.google_analytics %}{% verbatim %}
var _gaq = _gaq || [];_gaq.push(['_setAccount', '{% endraw %}{{ config.google_analytics }}{% raw %}']);{% endraw %}{% if config.google_analytics_domain %}{% raw %}_gaq.push(['_setDomainName', '{% endraw %}{{ config.google_analytics_domain }}{% raw %}']){% endraw %}{% endif %}{% if not config.google_analytics_domain %}{% raw %}_gaq.push(['_setDomainName', 'none']){% endraw %}{% endif %}{% raw %};_gaq.push(['_trackPageview']);(function() {var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;ga.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'stats.g.doubleclick.net/dc.js';var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);})();{% endraw %}{% endif %}
var _gaq = _gaq || [];_gaq.push(['_setAccount', '{% endverbatim %}{{ config.google_analytics }}{% verbatim %}']);{% endverbatim %}{% if config.google_analytics_domain %}{% verbatim %}_gaq.push(['_setDomainName', '{% endverbatim %}{{ config.google_analytics_domain }}{% verbatim %}']){% endverbatim %}{% endif %}{% if not config.google_analytics_domain %}{% verbatim %}_gaq.push(['_setDomainName', 'none']){% endverbatim %}{% endif %}{% verbatim %};_gaq.push(['_trackPageview']);(function() {var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;ga.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'stats.g.doubleclick.net/dc.js';var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);})();{% endverbatim %}{% endif %}
{% if config.statcounter_project and config.statcounter_security %}
var sc = document.createElement('script');

View File

@ -208,6 +208,6 @@
<input type="hidden" name="hash" value="{{ antibot.hash() }}">
</form>
<script type="text/javascript">{% raw %}
<script type="text/javascript">{% verbatim %}
rememberStuff();
{% endraw %}</script>
{% endverbatim %}</script>

View File

@ -1,4 +1,4 @@
{% filter remove_whitespace %}
{% apply remove_whitespace %}
{# tabs and new lines will be ignored #}
<div class="postcontainer" id="pc{{ post.id }}" data-board="{{ board.uri }}">
<div class="sidearrows">&gt;&gt;</div>
@ -20,7 +20,7 @@
{% include 'post/fileinfo.html' %}
{% include 'post/post_controls.html' %}
<div class="body" {% if post.files|length > 1 %}style="clear:both"{% endif %}>
{% endfilter %}{% if index %}{{ post.body|truncate_body(post.link) }}{% else %}{{ post.body }}{% endif %}{% filter remove_whitespace %}
{% endapply %}{% if index %}{{ post.body|truncate_body(post.link) }}{% else %}{{ post.body }}{% endif %}{% apply remove_whitespace %}
{% if post.modifiers['ban message'] %}
{{ config.mod.ban_message|sprintf(post.modifiers['ban message']) }}
{% endif %}
@ -30,4 +30,4 @@
</div>
</div>
</div>
{% endfilter %}
{% endapply %}

View File

@ -49,9 +49,9 @@
<br><a href="https://engine.vichan.net/">vichan</a> Copyright &copy; 2012-2016 vichan-devel</p>
</footer>
<div class="pages"></div>
<script type="text/javascript">{% raw %}
<script type="text/javascript">{% verbatim %}
ready();
{% endraw %}</script>
{% endverbatim %}</script>
</body>
</html>
{% endfilter %}

View File

@ -185,8 +185,8 @@
});
</script>
<script type="text/javascript">{% raw %}
<script type="text/javascript">{% verbatim %}
ready();
{% endraw %}</script>
{% endverbatim %}</script>
</body>
</html>

View File

@ -100,9 +100,9 @@
</footer>
<div class="pages"></div>
<script type="text/javascript">{% raw %}
<script type="text/javascript">{% verbatim %}
ready();
{% endraw %}</script>
{% endverbatim %}</script>
</body>
</html>
{% endfilter %}

View File

@ -52,9 +52,9 @@
</div>
<div class="pages"></div>
<script type="text/javascript">{% raw %}
<script type="text/javascript">{% verbatim %}
ready();
{% endraw %}</script>
{% endverbatim %}</script>
</body>
</html>

View File

@ -152,9 +152,9 @@
<br><a href="https://engine.vichan.net/">vichan</a> Copyright &copy; 2012-2016 vichan-devel</p>
</footer>
<div class="pages"></div>
<script type="text/javascript">{% raw %}
<script type="text/javascript">{% verbatim %}
ready();
{% endraw %}</script>
{% endverbatim %}</script>
</body>
</html>
{% endfilter %}

View File

@ -27,9 +27,9 @@
<iframe src="https://kiwiirc.com/nextclient/#irc://{{ settings.server }}:+{{ settings.port }}/#{{ settings.channel }}" width="800px" height="100%" scrolling="no"></iframe>
</div>
<div class="pages"></div>
<script type="text/javascript">{% raw %}
<script type="text/javascript">{% verbatim %}
ready();
{% endraw %}</script>
{% endverbatim %}</script>
</body>
</html>
{% endfilter %}

View File

@ -127,8 +127,8 @@ $(document).ready(function(){
<p style="text-align:center;"> To upload a voice-over / bump to radio click <a href="{{ settings.httpprefix ~ 'bump.html'}}" >here </a> </p>
</div>
<div class="pages"></div>
<script type="text/javascript">{% raw %}
<script type="text/javascript">{% verbatim %}
ready();
{% endraw %}</script>
{% endverbatim %}</script>
</body>
</html>

View File

@ -26,9 +26,9 @@
{% include 'rules.html' %}
<div class="pages"></div>
<script type="text/javascript">{% raw %}
<script type="text/javascript">{% verbatim %}
ready();
{% endraw %}</script>
{% endverbatim %}</script>
</body>
</html>
{% endfilter %}

View File

@ -72,9 +72,9 @@
<br><a href="https://github.com/lainchan/lainchan">lainchan</a> Copyright &copy; 2014-2017 lainchan Administration</p>
</footer>
<div class="pages"></div>
<script type="text/javascript">{% raw %}
<script type="text/javascript">{% verbatim %}
ready();
{% endraw %}</script>
{% endverbatim %}</script>
</body>
</html>
{% endfilter %}

View File

@ -174,8 +174,8 @@ function change_format(e) {
<br><a href="https://github.com/lainchan/lainchan">lainchan</a> Copyright &copy; 2014-2017 lainchan Administration</p>
</footer>
<div class="pages"></div>
<script type="text/javascript">{% raw %}
<script type="text/javascript">{% verbatim %}
ready();
{% endraw %}</script>
{% endverbatim %}</script>
</body>
</html>

View File

@ -111,9 +111,9 @@
</div>
<div class=pages></div>
</div>
<script type="text/javascript">{% raw %}
<script type="text/javascript">{% verbatim %}
ready();
{% endraw %}</script>
{% endverbatim %}</script>
<a href="#" id="bottom"></a>
</body>
</html>