summaryrefslogtreecommitdiffstats
path: root/roles/paste
diff options
context:
space:
mode:
authorRicky Elrod <codeblock@fedoraproject.org>2016-06-21 00:42:13 +0000
committerRicky Elrod <codeblock@fedoraproject.org>2016-06-21 00:42:13 +0000
commit82f1ddf39350a24c43b4eef22a8f7e63d56a2dbe (patch)
tree13f2575d6d31901e2540a78378a0c2dddd22c672 /roles/paste
parent27785b296b58ef63a2f247640ff95b50cf572237 (diff)
downloadansible-82f1ddf39350a24c43b4eef22a8f7e63d56a2dbe.tar.gz
ansible-82f1ddf39350a24c43b4eef22a8f7e63d56a2dbe.tar.xz
ansible-82f1ddf39350a24c43b4eef22a8f7e63d56a2dbe.zip
Add hotfix for sticky-notes JSON rendering
Signed-off-by: Ricky Elrod <codeblock@fedoraproject.org>
Diffstat (limited to 'roles/paste')
-rw-r--r--roles/paste/files/show.php12
1 files changed, 12 insertions, 0 deletions
diff --git a/roles/paste/files/show.php b/roles/paste/files/show.php
index 92d4c5aa7..333150a9c 100644
--- a/roles/paste/files/show.php
+++ b/roles/paste/files/show.php
@@ -228,6 +228,18 @@ $code_data = (empty($mode) ? $geshi->parse_code() : htmlspecialchars($row['data'
$lang->escape($code_data);
$skin->escape($code_data);
+// Fix JSON rendering. The JSON spec disallows newlines in string literals
+// https://www.ietf.org/rfc/rfc4627.txt :
+// "All Unicode characters may be placed within the
+// quotation marks except for the characters that must be escaped:
+// quotation mark, reverse solidus, and the control characters (U+0000
+// through U+001F)."
+// ... and since \n is a control character, sticky-notes putting newlines in
+// string literals (unescaped) breaks spec.
+if ($mode && $mode == 'json') {
+ $code_data = str_replace("\n", "\\n", $code_data);
+}
+
// Shorten the current URL
$url_shortener = new URLShortener();
$short_url = $url_shortener->shorten($nav->get_paste($row['id'], $hash, $project, true, ''));