Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 2 additions & 13 deletions doc/api/http_api.md
Original file line number Diff line number Diff line change
Expand Up @@ -285,16 +285,6 @@ sets the text of a pad
* `{code: 1, message:"padID does not exist", data: null}`
* `{code: 1, message:"text too long", data: null}`

#### setHTML(padID, html)
* API >= 1

sets the text of a pad based on HTML, HTML must be well formed. Malformed HTML will send a warning to the API log

*Example returns:*
* `{code: 0, message:"ok", data: null}`
* `{code: 1, message:"padID does not exist", data: null}`


#### getHTML(padID, [rev])
* API >= 1

Expand All @@ -304,15 +294,14 @@ returns the text of a pad formatted as HTML
* `{code: 0, message:"ok", data: {html:"Welcome Text<br>More Text"}}`
* `{code: 1, message:"padID does not exist", data: null}`

#### setHTML(padID, text)
#### setHTML(padID, html)
* API >= 1

sets the html of a pad
sets the text of a pad based on HTML, HTML must be well formed. Malformed HTML will send a warning to the API log.

*Example returns:*
* `{code: 0, message:"ok", data: null}`
* `{code: 1, message:"padID does not exist", data: null}`
* `{code: 1, message:"text too long", data: null}`

#### getAttributePool(padID)
* API >= 1.2.8
Expand Down
15 changes: 15 additions & 0 deletions src/node/db/API.js
Original file line number Diff line number Diff line change
Expand Up @@ -382,8 +382,23 @@ exports.getHTML = function(padID, rev, callback)
});
}

/**
setHTML(padID, html) sets the text of a pad based on HTML

Example returns:

{code: 0, message:"ok", data: null}
{code: 1, message:"padID does not exist", data: null}
*/
exports.setHTML = function(padID, html, callback)
{
//html is required
if(typeof html != "string")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this really qualify as input validation? :)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JohnMcLear
It's a basic input validation. :)
It fixes the server crashes if setHTML is called with no html parameter.

I stumbled across this issue when calling setHTML with the parameter text instead of html as the doc in current develop states.
The doc is already fixed in this branch.

You are welcome to propose a better fix for this issue.

{
callback(new customError("html is no string","apierror"));
return;
}

//get the pad
getPadSafe(padID, true, function(err, pad)
{
Expand Down