Skip to content

Commit

Permalink
fixed fatal error on windows (JSON library did not escape keys in Dic…
Browse files Browse the repository at this point in the history
…tionary<string, string>)
  • Loading branch information
darwin committed Jun 21, 2009
1 parent 2491105 commit 006480e
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 246 deletions.
76 changes: 0 additions & 76 deletions src/XRefreshExtension.csproj

This file was deleted.

159 changes: 0 additions & 159 deletions src/XRefreshSetup.csproj

This file was deleted.

9 changes: 6 additions & 3 deletions src/firefox/chrome/content/xrefresh.js
@@ -1,4 +1,4 @@
// we use UTF-8 encoded JSON to exchange messages between extension and server
// we use UTF-8 encoded JSON to exchange messages between extension and server
//
// this source contains copy&pasted various bits from Firebug sources.

Expand Down Expand Up @@ -145,9 +145,11 @@ FBL.ns(function() {
var parts = data.split(messageSeparator);
for (var i = 0; i < parts.length-1; i++) {
var buffer = UTF8.decode(parts[i]);
var message = JSON.parse(buffer);
try {
var message = JSON.parse(buffer);
} catch (e) {}
if (!message) {
module.error("Enable to parse server JSON message: "+message);
module.error("Unable to parse server JSON message: "+buffer);
continue;
}
dbg(" message:", message);
Expand Down Expand Up @@ -855,6 +857,7 @@ FBL.ns(function() {
},
/////////////////////////////////////////////////////////////////////////////////////////
doesCSSNameMatch: function(cssLink, cssFile) {
cssFile = cssFile.replace('\\', '/'); // convert windows backslashes to forward slashes
var firstQ = cssLink.indexOf('?');
if (firstQ != -1) cssLink = cssLink.substring(0, firstQ);
var lastLinkSlash = cssLink.lastIndexOf('/');
Expand Down
23 changes: 16 additions & 7 deletions src/winmonitor/Server.cs
Expand Up @@ -86,7 +86,7 @@ private string RelativePath(string path, string root)
public string name;
public string type;
public File[] files;
public Dictionary<string, string> contents = new Dictionary<string,string>();
public Dictionary<string, object> contents = new Dictionary<string, object>();

public ServerMessageRefresh(Model.FoldersRow folder, bool positive)
: base("DoRefresh")
Expand Down Expand Up @@ -157,12 +157,21 @@ public ServerMessageRefresh(Model.FoldersRow folder, bool positive)
{
if (activity.passed)
{
files[i] = new File(root, activity);
if (activity.path1.EndsWith(".css")) {
TextReader tr = new StreamReader(root + "\\" + files[i].path1);
string content = tr.ReadToEnd();
tr.Close();
contents[files[i].path1] = content;
files[i] = new File(root, activity);
try // file reading may throw, because someone deletes the file or something, so we should be safe here
{
if (activity.path1.EndsWith(".css"))
{
TextReader tr = new StreamReader(root + "\\" + files[i].path1);
string content = tr.ReadToEnd();
tr.Close();
// HACK: JSON library does not escape keys in dictionary!!!
string key = JavaScriptUtils.EscapeJavaScriptString(files[i].path1, '"', false);
contents[key] = content;
}
}
catch (Exception)
{
}
i++;
}
Expand Down
3 changes: 2 additions & 1 deletion test/style.css
@@ -1,3 +1,4 @@
html {
background-color: lightGreen;
background-color: white;
font-size: 20px;
}

0 comments on commit 006480e

Please sign in to comment.