# // preview.awk
# // Display the post list
# // 30.03.2015
# //
# // Copyright (C) 2015 Balthasar SzczepaĆski
# //
# // This program is free software: you can redistribute it and/or modify
# // it under the terms of the GNU Affero General Public License as
# // published by the Free Software Foundation, either version 3 of the
# // License, or (at your option) any later version.
# //
# // This program is distributed in the hope that it will be useful,
# // but WITHOUT ANY WARRANTY; without even the implied warranty of
# // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# // GNU Affero General Public License for more details.
# //
# // You should have received a copy of the GNU Affero General Public License
# // along with this program. If not, see
" } else { if(tagvalue !~ /^\".*\"$/) #"#\"" tagvalue="You forgot about the quote marks, "htmlescape(tagvalue) else tagvalue=bb2html(substr(tagvalue,2,length(tagvalue)-2)) html = html ""tagvalue" wrote:" else if (tagname=="list") { if (tagvalue=="") html=html"" else html=html"" } else if (tagname=="*") html=html"" else if (tagname == "br") # { # } else { debug = debug "\nunknown tag" html = html htmlescape(tag) } count[depth]="" --depth ++count[depth] } else if(count[depth]>bbtree[indt(count,depth)".n"]) { debug = debug "\nrun out of elements in this tag; leaving" count[depth]="" --depth ++count[depth] } else { tag=bbtree[ind(count,depth)] debug = debug "\ntext: "tag tag=htmlescape(tag) if(bbtree[indt(count,depth)".t"] == "code") { gsub(/ /,"\\ ",tag) gsub(/\t/,"\\ \\ ",tag) } if(nourl==""&& bbtree[indt(count,depth)".t"] !~ /^((code)|(img)|(url))$/) gsub(/https?:\/\/[^\n\r\t<> ]+/,"&",tag) if(nosmil=="" && bbtree[indt(count,depth)".t"] !~ /^((code)|(img))$/) { gsub(/(^|[\n\r\t ]):D($|[\n\r\t ])/," ",tag) gsub(/(^|[\n\r\t ]):\)($|[\n\r\t ])/," ",tag) gsub(/(^|[\n\r\t ]):\(($|[\n\r\t ])/," ",tag) gsub(/(^|[\n\r\t ]):o($|[\n\r\t ])/," ",tag) gsub(/(^|[\n\r\t ]):shock:($|[\n\r\t ])/," ",tag) gsub(/(^|[\n\r\t ]):\?($|[\n\r\t ])/," ",tag) gsub(/(^|[\n\r\t ])8-\)($|[\n\r\t ])/," ",tag) gsub(/(^|[\n\r\t ]):lol:($|[\n\r\t ])/," ",tag) gsub(/(^|[\n\r\t ]):x($|[\n\r\t ])/," ",tag) gsub(/(^|[\n\r\t ]):P($|[\n\r\t ])/," ",tag) gsub(/(^|[\n\r\t ]):oops:($|[\n\r\t ])/," ",tag) gsub(/(^|[\n\r\t ]):cry:($|[\n\r\t ])/," ",tag) gsub(/(^|[\n\r\t ]):evil:($|[\n\r\t ])/," ",tag) gsub(/(^|[\n\r\t ]):twisted:($|[\n\r\t ])/," ",tag) gsub(/(^|[\n\r\t ]):roll:($|[\n\r\t ])/," ",tag) gsub(/(^|[\n\r\t ]):wink:($|[\n\r\t ])/," ",tag) gsub(/(^|[\n\r\t ]);\)($|[\n\r\t ])/," ",tag) gsub(/(^|[\n\r\t ]):!:($|[\n\r\t ])/," ",tag) gsub(/(^|[\n\r\t ]):\?:($|[\n\r\t ])/," ",tag) gsub(/(^|[\n\r\t ]):idea:($|[\n\r\t ])/," ",tag) gsub(/(^|[\n\r\t ]):arrow:($|[\n\r\t ])/," ",tag) gsub(/(^|[\n\r\t ]):\|($|[\n\r\t ])/," ",tag) gsub(/(^|[\n\r\t ]):mrgreen:($|[\n\r\t ])/," ",tag) } html = html tag ++count[depth] } } debug = debug "\ndone\n" return html } function ind(count,depth, ii,iindex) { iindex = "" for(ii=0;ii<=depth;++ii) { if(ii!=0) iindex = iindex "." iindex = iindex count[ii] } # debug = debug "\n" iindex return iindex } function indt(count,depth, ii,iindex) { iindex = "" for(ii=0;ii
" } } else if (tagname == "b") { html = html"" if(tagvalue!="") html=html"This tag shouldn't have any value. " } else if (tagname == "i") { html = html"" if(tagvalue!="") html=html"This tag shouldn't have any value. " } else if (tagname == "u") { html = html"" if(tagvalue!="") html=html"This tag shouldn't have any value. " } else if (tagname == "code") { if(bbtree[indtu(count,depth)".t"] == "code") { html=html htmlescape(tag) debug = debug "\nnot a tag, actually" } else { html=html"
- Code: Select all
" if(tagvalue!="") html=html"This tag shouldn't have any value. " } } else if (tagname == "img") html=html"" } else if (tagname == "size") { if (tagvalue==""||(tagvalue !~ /^[0-9]+$/)||(tagvalue+0)>200) html=html" This tag should have a correct value. " else html=html"" } else if (tagname == "color") { if (tagvalue==""||tagvalue !~ /^#[0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F]$/) #for some reason /^([0-9A-F]{6})$/ doesn't work. html=html" This tag should have a correct value. " else html=html"" } else if (tagname ~ /^((center)|(right))$/) { html=html"
" if(tagvalue!="") html=html"This tag shouldn't have any value. " } else if (tagname =="s") { html=html"" if(tagvalue!="") html=html"This tag shouldn't have any value. " } else if (tagname =="sub") { html=html"" if(tagvalue!="") html=html"This tag shouldn't have any value. " } else if (tagname =="sup") { html=html"" if(tagvalue!="") html=html"This tag shouldn't have any value. " } else if (tagname=="spoiler") { html=html"Spoiler:" else if (tagname =="s") html=html"" else if (tagname =="sub") html=html"" else if (tagname =="sup") html=html"" else if (tagname=="spoiler") html=html"" if(tagvalue!="") html=html"This tag shouldn't have any value. " } else if (tagname=="list") { if(tagvalue=="") html=html"" else if (tagname ~/^(b|i|u|(size)|(color))$/) html = html"" else if (tagname == "code") { if(bbtree[indtu(count,depth)".t"] == "code") { html=html htmlescape(tag) debug = debug "\nnot a tag, actually" } else html = html"" } else if (tagname == "img") { html = html"\" alt=\"Image\" />" if(tagvalue!="") html=html"This tag shouldn't have any value. " } else if(tagname=="url") html=html"" else if (tagname ~ /^((center)|(right))$/) html=html"" else { if (tagvalue=="1") tagvalue="decimal" else if (tagvalue=="i") tagvalue="lower-roman" else if (tagvalue=="I") tagvalue="upper-roman" else if (tagvalue=="a") tagvalue="lower-alpha" else if (tagvalue=="A") tagvalue="upper-alpha" else { html=html"This tag should have a correct value. " tagvalue="decimal" } html=html"
" } } else if (tagname=="*") { html=html"
- " if(tagvalue!="") html=html"This tag shouldn't have any value. " } else if (tagname == "br") { html = html"
" if(tagvalue!="") html=html"This tag shouldn't have any value. " } else { debug = debug "\nunknown tag" html = html htmlescape(tag) } ++count[depth] } else if(bbtree[ind(count,depth)".k"]=="s") { debug = debug "\nentering tag:" ++depth count[depth]=0 } else if(bbtree[ind(count,depth)".k"]=="e") { debug = debug "\nleaving tag:" tag=bbtree[ind(count,depth)] tagname=bbtree[ind(count,depth)".t"] tagvalue=bbtree[ind(count,depth)".v"] debug = debug "\nname: "tagname" value: "tagvalue if (tagname == "post") { } else if(bbtree[ind(count,depth)".m"]=="") { debug = debug "\nunmatched" html = html htmlescape(tag) } else if(tagname == "quote") html = html "0) iindex=iindex"." iindex = iindex "0" # debug = debug "\n" iindex return iindex } function indtu(count,depth, ii,iindex) { iindex = "" for(ii=0;ii 0) iindex=iindex"." iindex = iindex "0" # debug = debug "\n" iindex return iindex } function htmlescape(name,less,br, len,iii,escaped,ch) { len=length(name) escaped="" for(iii=1;iii<=len;++iii) { ch=substr(name,iii,1); if(ch == "\n") escaped = escaped ((br!="")?"
":""ch2dec[ch]";") else if(ch =="\r") escaped = escaped ((br!="")?"":""ch2dec[ch]";") else if(ch == "\"" && less=="") escaped = escaped ""ch2dec[ch]";" else if(ch ~ /[=<>&]/) escaped = escaped ""ch2dec[ch]";" else escaped = escaped ch } return escaped } function hexencode(name, len,iii,escaped,ch) { len=length(name) escaped="" for(iii=1;iii<=len;++iii) { ch=substr(name,iii,1) escaped = escaped ch2hex[ch] } return escaped }