Page 1 of 1

custom stylesheet loses newlines

Posted: 07 Feb 2012, 22:06
by gmargo
I've been using a custom stylesheet to highlight the current article's headline. It's not fancy; just in case you're interested, here it is:

Code: Select all

.even.Selected a.title {
    font-size : 120%;
    font-weight : bold;
    color: #1155CC;
}

.odd.Selected a.title {
    font-size : 120%;
    font-weight : bold;
    color: #1155CC;
}

But I have found that editing the "custom stylesheet" on the preferences page is difficult because the newlines get stripped out.

There is code to replace newlines with html breaks, but then the db_escape_string() routine strips the html breaks back out. One way to fix this is shown below; just don't strip tags. An alternative might be to make a special case for $key == "USER_STYLESHEET". Another alternative it to not replace newlines with breaks.


Code: Select all

diff --git a/classes/rpc.php b/classes/rpc.php
index ef89a21..e03a597 100644
--- a/classes/rpc.php
+++ b/classes/rpc.php
@@ -213,7 +213,7 @@ class RPC extends Protected_Handler {
       $value = str_replace("\n", "<br/>", $_REQUEST['value']);
 
       $key = db_escape_string($_REQUEST["key"]);
-      $value = db_escape_string($value);
+      $value = db_escape_string($value, $strip_tags=false);
 
       set_pref($this->link, $key, $value);
 

Re: custom stylesheet loses newlines

Posted: 13 Feb 2012, 13:38
by fox
Sorry for the delay, thanks for reporting this. Should be fixed in trunk.