mirror of
https://github.com/neocities/neocities.git
synced 2025-08-01 23:31:52 +02:00
massive update to deprecate site_file/upload in favor of api/upload, improve dashboard. todo: webdav switchover, dashboard error/result messages
This commit is contained in:
parent
577cd0a82a
commit
943271b509
10 changed files with 467 additions and 373 deletions
|
@ -131,3 +131,15 @@ def hcaptcha_valid?
|
|||
false
|
||||
end
|
||||
end
|
||||
|
||||
JS_ESCAPE_MAP = {"\\" => "\\\\", "</" => '<\/', "\r\n" => '\n', "\n" => '\n', "\r" => '\n', '"' => '\\"', "'" => "\\'", "`" => "\\`", "$" => "\\$"}
|
||||
|
||||
def escape_javascript(javascript)
|
||||
javascript = javascript.to_s
|
||||
if javascript.empty?
|
||||
result = ""
|
||||
else
|
||||
result = javascript.gsub(/(\\|<\/|\r\n|\342\200\250|\342\200\251|[\n\r"']|[`]|[$])/u, JS_ESCAPE_MAP)
|
||||
end
|
||||
result
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue