Skip to content

Commit

Permalink
escaping %
Browse files Browse the repository at this point in the history
  • Loading branch information
awalterschulze committed Dec 17, 2015
1 parent 9db08f5 commit d9e70ab
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 28 deletions.
12 changes: 8 additions & 4 deletions form/form.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,11 +163,15 @@ function replaceAll(str, search, replace) {
return str.split(search).join(replace);
}
function escapeIllegal(str) {
return replaceAll(replaceAll(str, "%", "%25"), "&", "%26");
}
function getFields(node) {
var nodeJson = {};
$("> div.field > div ", $(node)).each(function(idx, field) {
$("> input[type=text]", $(field)).each(function(idx, input) {
nodeJson[$(input).attr("name")] = replaceAll($(input).val(), "&", "%26");
nodeJson[$(input).attr("name")] = escapeIllegal($(input).val());
});
$("> input[type=number][step=any]", $(field)).each(function(idx, input) {
nodeJson[$(input).attr("name")] = parseFloat($(input).val());
Expand All @@ -191,7 +195,7 @@ function getFields(node) {
if (isInt(textvalue)) {
nodeJson[$(input).attr("name")] = parseInt(textvalue);
} else {
nodeJson[$(input).attr("name")] = replaceAll(textvalue, "&", "%26");
nodeJson[$(input).attr("name")] = escapeIllegal(textvalue);
}
});
});
Expand All @@ -201,7 +205,7 @@ function getFields(node) {
if (!(fieldname in nodeJson)) {
nodeJson[fieldname] = [];
}
nodeJson[fieldname].push(replaceAll($(input).val(), "&", "%26"));
nodeJson[fieldname].push(escapeIllegal($(input).val()));
});
$("input[type=checkbox]", $(field)).each(function(idx, input) {
var fieldname = $(input).attr("name");
Expand Down Expand Up @@ -241,7 +245,7 @@ function getFields(node) {
if (isInt(textvalue)) {
nodeJson[fieldname].push(parseInt(textvalue));
} else {
nodeJson[fieldname].push(replaceAll(textvalue, "&", "%26"));
nodeJson[fieldname].push(escapeIllegal(textvalue));
}
});
});
Expand Down
48 changes: 32 additions & 16 deletions test/grpc.letmegrpc.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 8 additions & 4 deletions testimport/import.letmegrpc.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 8 additions & 4 deletions testproto2/proto2.letmegrpc.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit d9e70ab

Please sign in to comment.