Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

Commit

Permalink
Fixed fix for #3
Browse files Browse the repository at this point in the history
  • Loading branch information
eglia committed Mar 14, 2016
1 parent cc02bfa commit 654aa1b
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 4 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
## Changelog
### 0.2.10
- Fixed regression introduced in 0.2.9 which caused the addon to break

### 0.2.9
- Fixed character escape ([#3](https://github.com/eglia/ff-oc-passwords/issues/3))

Expand Down
41 changes: 38 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,40 @@ function fetchLoginList(databaseHost, databaseUser, databasePassword) {
passwordRequest.get();
}

function escapeJSON(text) {
var quoteCounter = 0;
var quotePosition = [];
var returnText = text;
returnText = returnText.replace(/\n/g, "\\n");
for (var i=0; i<returnText.length; i++) {
if (returnText[i] == "\"") {
quoteCounter = quoteCounter + 1;
quotePosition.push(i);
}
else if (returnText[i] == ":" || returnText[i] == ",") {
if (quoteCounter != 2) {
quotePosition.splice(-1-quoteCounter, 1);
quotePosition.splice(-1, 1);
}
else {
quotePosition = quotePosition.slice(0, -2)
}
quoteCounter = 0;
}
}
if (quoteCounter != 2) {
quotePosition.splice(-1-quoteCounter, 1);
quotePosition.splice(-1, 1);
}
else {
quotePosition = quotePosition.slice(0, -2)
}
for (var i=0; i<quotePosition.length; i++) {
returnText = returnText.substr(0, quotePosition[i]+i) + "\\\"" + returnText.substr(quotePosition[i]+i+1);
}
return returnText;
}

var userList = [];
var passwordList = [];

Expand All @@ -173,11 +207,12 @@ function processLoginList() {
var hits = 0
for (var i=0; i<loginList.length; i++) {
var entryProperties = "{" + loginList[i]["properties"] + "}";
entryProperties = JSON.stringify(entryProperties);
var entryAddress = getHostFromURL(JSON.parse(entryProperties)["address"])
entryProperties = escapeJSON(entryProperties);
entryProperties = JSON.parse(entryProperties);
var entryAddress = getHostFromURL(entryProperties["address"])
var entryWebsite = getHostFromURL(loginList[i]["website"])
if (host == entryAddress || host == entryWebsite) {
userList.push(JSON.parse(entryProperties)["loginname"]);
userList.push(entryProperties["loginname"]);
passwordList.push(loginList[i]["pass"]);
hits = hits + 1;
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"title": "ownCloud Passwords",
"name": "ff-oc-passwords",
"version": "0.2.9",
"version": "0.2.10",
"description": "A Firefox add-on to access passwords stored in an ownCloud.",
"homepage": "https://github.com/eglia/ff-oc-passwords",
"main": "index.js",
Expand Down

0 comments on commit 654aa1b

Please sign in to comment.