Error while validating epub in epubcheck, it says this - epub

Error while parsing file: element "ruby" not allowed anywhere;
expected the element end-tag, text or element "a", "abbr", "acronym",
"applet", "b", "bdo", "big", "br", "cite", "code", "del", "dfn", "em",
"i", "iframe", "img", "ins", "kbd", "map", "noscript", "ns:svg",
"object", "q", "samp", "script", "small", "span", "strong", "sub",
"sup", "tt" or "var" (with xmlns:ns="http://www.w3.org/2000/svg")
and the code where it is pointing this error looks like this
<p>i don't want this<ruby>Artifact<rt>Variable Drag-Ride</rt></ruby>.</p>
can you tell me why this error is coming

Ruby tags should be supported in epub3 (search for "ruby" in this reference) but here the element is probably inside a tag where it's not allowed (xhtml is very strict).
Search for the sentence and look for the previous tags, they may have some restrictions resulting in this error on epubcheck.

Related

Creating multiple resources in tandem with JSONAPI:Resources for Rails

On my application, I would like to add a post and user in tandem using jsonapi:resources. A user can be created already. And a post can be created already if someone is signed in. However for this special scenario I would like a user to be able to submit their first post while creating their account. Here is the payload that would be submitted.
{
"data":{
"user":{
"attributes":{
"name": "blah blah",
"age": 20,
"address": "mickey mouse street"
}
},
"relationships": {
"post": {
"content": "this is a new post",
"type": "blog"
}
}
}
}
Is this at all possible? If so in which resource file would I create them both? Would it be the resource file for posts or for users? Or would it be best practice to create the user first and then once the user has been created make a separate call to create the post? Thanks!

Rails: security implications of whitelisting table tags in Rails' sanitizer?

I see that Rails doesn't whitelist table tags by default for its sanitizer. Is there any particular security reason for this? I can't think of any, but I'm using CKEditor to allow user input of HTML tags, and I'd like them to use tables if they want (so long as there isn't some sort of risk that I'm unaware of). This is my first application where I'm allowing users to set HTML tags, so while I can't find any reason not to, I'm still a bit anxious about it.
In a Rails GitHub issue, there was discussion about using Loofah's newer list, but the Rails devs decided that they would continue to use the whitelist from Rails 4.1, but there wasn't a clear answer on if there was a security risk with table tags.
BTW, to save people time in figuring out which tags are whitelisted in their version of Rails (which is surprisingly difficult to find), you can go to console (this is for Rails 5.1.4):
Rails::Html::Sanitizer.white_list_sanitizer.allowed_tags
=> #<Set: {"strong", "em", "b", "i", "p", "code", "pre", "tt", "samp",
"kbd", "var", "sub", "sup", "dfn", "cite", "big", "small", "address", "hr",
"br", "div", "span", "h1", "h2", "h3", "h4", "h5", "h6", "ul", "ol", "li",
"dl", "dt", "dd", "abbr", "acronym", "a", "img", "blockquote", "del", "ins"}>
Rails::Html::Sanitizer.white_list_sanitizer.allowed_attributes
=> #<Set: {"href", "src", "width", "height", "alt", "cite", "datetime",
"title", "class", "name", "xml:lang", "abbr"}>

How can I embed HTML tags into a JSON object in Rails?

I have a simple hash containing a description:
simple_hash = { "description" => "<p>This is my description.</p>" }
I need write this out to a file. In the file, this hash needs to be represented as JSON:
simple_hash.to_json
But this is what I'm actually getting:
"{\"description\":\"\\u003cp\\u003eThis is my description.\\u003c/p\\u003e\"}"
How do I stop to_json from doing that to my HTML tags?
to_json is doing the safe thing encoding the HTML.
If you are certain that it is safe, you can easily decode with Rails' JSON.parse
>> JSON.parse "{\"desc\":\"\\u003cp\\u003eThis is my description.\\u003c/p\\u003e\"}"
=> {"desc"=>"<p>This is my description.</p>"}
You could try doing this:
def json_template(id)
###################
# Method to create the json templates
###################
File.open("test_dir/temp_file.json", 'w'){|i|
templ = %Q<{
"id": "#{Random.rand(20)}#{Random.rand(20)}",
"version": 1.0.1.1,
"service": "ftp",
"os": "linux"
}>
i.write(templ)
}
end

docusign_rest gem not populating tab from template

I am trying to test the docusign_rest gem for possible integration into my rails app. I have set up the gem and configured it with my username, password, and integrator key. I have set the version of the api to 'v2' and checked all the of the names of both the signers and the tab fields multiple times. Here is the code I am using to make the request:
response = c.create_envelope_from_template(
status: 'sent',
email: {
subject: "Test email subject",
body: "Test email body",
},
template_id: template["templateId"],
signers: [
{
embedded: false,
name: "Name",
email: 'example#gmail.com',
role_name: "Signer1",
tabs: {
textTabs: [
{
tabLabel: "\\*address",
value: "123 Example St.",
locked: true
}
]
}
}
]
)
The request gets sent and the envelope gets sent but the 'address' field is not populated. Is there anything I am doing obviously wrong?
Thanks in advance.
Try changing the signers node in you request body to templateRoles. When you use templates in DocuSign instead of specifying the signers and their types and tabs, you assign them to existing template roles that are configured in the template. That's why no signer types should be specified in this call, just the template roles that each recipient will get matched to, and the values of any tabs you want to populate.
I've never used Ruby before so there might be some formatting or syntax issues I'm missing here, and I also have never seen the ruby gem you're referring to so not sure how stable or correct that code is. But basically this is what I think you need to do...
Right now you have:
status: 'sent',
email: {
subject: "Test email subject",
body: "Test email body",
},
template_id: template["templateId"],
signers: [
{
...
Try changing signers to templateRoles, like so:
status: 'sent',
email: {
subject: "Test email subject",
body: "Test email body",
},
template_id: template["templateId"],
templateRoles: [
{
...
The resulting http request body that you need to construct should look something like the following (in JSON format):
{
"emailSubject": "DocuSign API - Signature Request from Template",
"templateId": "ABCD1234",
"templateRoles": [
{
"email": "firstperson#email.com",
"name": "John Doe",
"roleName": "Template Role Name goes here",
"tabs": [
{
"textTabs": [
{
"tabLabel": "\\*address",
"value": "432 Sorrento Dr.",
"locked": "true"
}
]
}
]
}
],
"status": "sent"
}
Lastly, the DocuSign API Walkthrough for requesting a signature from a template is a great resource for sending from a template so this might help too. There's sample code for making this api call in 6 different languages (unfortunately Ruby is not one of them):
http://iodocs.docusign.com/APIWalkthrough/requestSignatureFromTemplate
Finally figured it out myself by modifying the gem to inspect the request. With the docusign_rest gem, the documentation on the github page is incorrect. The tabs dictionary should not be there and the items in this specific request should be underscore separated instead of camel case. Therefore, the actual request would look something like:
response = c.create_envelope_from_template(
status: 'sent',
email: {
subject: 'Test email subject',
body: 'Test email body',
},
template_id: template["templateId"],
signers: [
{
embedded: false,
name: 'Name',
email: 'example#gmail.com',
role_name: 'Signer1',
text_tabs: [
{
label: 'Address',
name: 'Address',
value: '123 Example Street.',
}
]
}
]
)
This request will allow you with the gem and v2 of the api to create an envelope from a template and prepopulate any fields. All other field types go the same way as the text_tabs array.

Received error response when Get a Facebook user's basic info

I'm doing it on ios. When I get a user's info(gendar,locale,etc), such as Bill Gates(216311481960), it will return error. Maybe because these info are not public. If I just get name,link, picture, that will be OK. But how can I handle this kind of error. How can I know which info can be retrieved?
Thanks.
Without a user access token, pubic info can be grabbed this way: http://graph.facebook.com/216311481960
{
"id": "216311481960",
"name": "Bill Gates",
"picture": "http://profile.ak.fbcdn.net/hprofile-ak-snc4/276582_216311481960_498814368_s.jpg",
"link": "http://www.facebook.com/BillGates",
"likes": 1216122,
"category": "Public figure",
"is_published": true,
"website": "www.thegatesnotes.com www.gatesfoundation.org",
"username": "BillGates",
"talking_about_count": 25035
}
As you can see this doesn't appear to be user information, but rather page information.
For user information, you need to use a Facebook user id. Zuck's is 4...so do: http://graph.facebook.com/4
{
"id": "4",
"name": "Mark Zuckerberg",
"first_name": "Mark",
"last_name": "Zuckerberg",
"link": "http://www.facebook.com/zuck",
"username": "zuck",
"gender": "male",
"locale": "en_US"
}
Notice how it has both first_name and last_name, while the "Bill Gates" one you have as an example is clearly not a "user" but a page.
With a valid user access token, all shared information can be grabbed this way:
http://graph.facebook.com/me?access_token=ValidUserAccessToken

Resources