Goutte with behat: xml string as textarea value is filled with html entities - html-entities

I have a page that contains a form with some input elements, including a textarea. Those input fields are populated with some values. Think of this whole page as an edit page for some entity. Textarea contains an XML string that shows properly within normal browser (eg. firefox and chrome) and looks like following:
<front>
<!-- top row -->
<cell>
<page>8</page>
</cell>
</front>
But when i run the test case with goutte mink driver the page is loaded and the value of textarea is encoded with special characters, like so:
<front>
<!-- top row -->
<cell>
<page>8</page>
</cell>
</front>
And when i press submit button that mess is sent to the server and saved instead of initial correct xml. Note that i do not touch it at all. I can just load the page and press submit button and it's all screwed. This happens only with goutte, but not with, say, selenium2.
So the question is: how can i force goutte interpret those html entities automatically and send them as correct data, not that encoded mess?

there's no solution for that. It seems as normal behavior of Goutte/Guzzle. As a workaround we ended up with following solution: in case Goutte driver is used we check page contents for all <textarea> elements, and if any found then for each we get their contents and plainly reinsert as follows:
$elements = $this->pageContent->findAll('xpath', '//textarea');
foreach ($elements as $element) {
$element->setValue($element->getText());
}

Related

<pre> tag automatically added - HTMLCodeFormat() and HTMLEditFormat()

I have a form with several TinyMCE textareas. Content is loaded in some textareas when the form is called. Other textareas are empty.
The content that is preloaded into the text fields already has a <p> tag. Everything is fine with it. But i have a problem with the empty textareas. TinyMCE automatically adds a <pre> tag, which destroys the formatting and layout.
This is the process that leads to the problem:
Open the form and enter unformatted text to a empty textarea.
Save the form. The content is displayed correctly. Everything is fine so far.
Edit the form / content.
At this point, TinyMCE adds the pre tag. The tag is not yet saved in the database, it comes from the editor.
I also made some tests with preloaded content. This is the result.
Template code | TinyMCE textarea
<p>test</p> | <p>test</p>
test | <pre>test</pre>
How can I prevent TinyMCE from adding the <pre> tag? Alternatively, <pre> could also be replaced by <p>.
If you're on ColdFusion 10 or later, you should be using the OWASP ESAPI encoding functions. They handle a higher range of character encoding than HTMLEditFormat() and HTMLCodeFormat().
Output between HTML tags: <td>#encodeForHTML(variables.myVar)#</td>
Output in an HTML attribute: <input type="text" value="#encodeForHtmlAttribute(variables.myVar)#">
The cause of the problem was the use of HTMLCodeFormat instead of HTMLEditFormat before I handed the content over to TinyMCE. Both have nearly the same effect, but HTMLCodeFormat adds a <pre> tag in addition.
HTMLCodeFormat()
HTMLEditFormat()

OrchardCMS Replacement Tokens for Query Results displaying HTML tags instead rendering them

I am having problems understanding the token system for the output of query / projections.
If I leave the property as is it displays the text content with HTML formatting intact.
But I need to wrap it with a tag, the html tags get displayed as text.
Rewrite Results -> Rewrite output
<div class="collapse" id="toggle_{Content.Id}">
{Content.Fields.CaseStudy.ClientChallenge} </div>
I am trying to create a collapsible text area, I already have a button that hides/unhides the content.
Why is it displaying as text instead of rendering the tags properly.
I think this is because I don't know how replacement tokens work.
Another example problem is up one level on the edit Layout, I want to set the item class to work-item {Category}, Category being the name/title of a property, which I am using for grouping.
Right above the projection: I want to include some html that lists all the Categorys in a ul i.e. data-filter=".experiential" I have tried things like: work-item {Category} and work-item {Content.Fields.CaseStudy.Category}. Category is a "term" (?) from a taxonomy.
I feel like I am failing to understand how it all works.
Submitted as a bug https://github.com/OrchardCMS/Orchard/issues/7355
Will edit and post if it is fixed. In case anoyong else comes across this issue.

Sitecore: RTE Paste as Plain Text customization

I was experimenting with RTE buttons and found that the copy pasting from word to RTE allows all styles to be intact. So i read a post and got rid of the extra formatting. Now i want to deal with blank spaces and line breaks. So, with some analysis i have decided to allow:
One blank space for single line break. Statements to be shown as single paragraph.For example
"This is new. </br> This is weird." should become "<p>This is new. This is weird.</p>"
If multiple line breaks are found, then all break separated statements should act as single paragraph with only single break between them. For example
"This is new. </br></br></br> This is weird." should become "<p>This is new.</p> </br> <p>This is weird.</p>"
This would be very efficient for authors which previously would need to adjust the whole scrap after pasting from word.
I have tried using the "Paste as Plain Text" button but it does not take care of line breaks. So i was wondering how i could customize the button function to adjust it to my needs? where and how should i do this ??
In web.config file, you can change and update HTMLEditor setting. However, you might have different aspect and dynamic user's input in the HTML editor. So, I would suggest you create a customize RichText Editor in Core DB and an assembly if you need. Then, create another config file in App_include folder to patch and add your customized HTML editor with different setting. Below is from web.config file and you can update this configuration if you want to keep using default RichText Editor.
<!-- HTML EDITOR DEFAULT CONFIGURATION TYPE
Specifies the type responsible for setting up the rich text editor. Can be overriden at profile level. Must inherit from
Sitecore.Shell.Controls.RichTextEditor.EditorConfiguration,Sitecore.Client.
Default value: Sitecore.Shell.Controls.RichTextEditor.EditorConfiguration,Sitecore.Client
-->
<setting name="HtmlEditor.DefaultConfigurationType" value="Sitecore.Shell.Controls.RichTextEditor.EditorConfiguration,Sitecore.Client" />
<!-- HTML EDITOR DEFAULT PROFILE
Path to the default html editor profile.
Default value: /sitecore/system/Settings/Html Editor Profiles/Rich Text Default
-->
<setting name="HtmlEditor.DefaultProfile" value="/sitecore/system/Settings/Html Editor Profiles/Rich Text Default" />
<!-- HTML EDITOR LINE BREAK
Specifies the tag that the HTML editor inserts on Enter. Values can be
"br", "div" and "p".
-->
<setting name="HtmlEditor.LineBreak" value="p" />
<!-- HTML EDITOR REMOVE SCRIPTS
If true, the rich text editor removes script tags from RTE field values before saving. Setting the value to true reduces the potential for cross-site scripting and other script-related issues.
Default value: true
-->
<setting name="HtmlEditor.RemoveScripts" value="true" />
<!-- HTML EDITOR SUPPORT WEB CONTROLS
Indicates if the Html Editor supports web controls. If true, Web Controls are shown as yellow boxes.
Default value: true
-->
<setting name="HtmlEditor.SupportWebControls" value="true" />
<!-- HTML EDITOR VALIDATOR SERVICE URL
Specifies the url that validates XHtml.
-->
<setting name="HtmlEditor.ValidatorServiceUrl" value="http://validator.w3.org/check" />
You have to do this change in your Javascript... you can have custom JS when you are in authoring mode to catch the paste event and do the HTML manipulation in javascript...
An other option that would work as well in the ContentTree would be to add a button in the RTE that call this javascript, here you can find some explanation on how to add the button to the RTE.
https://markstiles.net/Blog/2011/02/05/adding-button-to-rich-text-editor.aspx

DocuSign API: Pre-filling radio group tabs for template

I have radio groups setup in my DocuSign template, and am trying to fill it up while creating an envelope using the template. Here's the XML structure that I've made:
<envelopeDefinition xmlns="http://www.docusign.com/restapi">
<accountId>******</accountId>
<status>sent</status>
<templateId>******</templateId>
<templateRoles>
<templateRole>
<email>******#test.com</email>
<name>****** ******</name>
<roleName>General</roleName>
<clientUserId>UserId</clientUserId>
<tabs>
<textTabs>
<text>
<tabLabel>Name</tabLabel>
<value>Test User</value>
</text>
<text>
<tabLabel>Address 1</tabLabel>
<value>123 Main Street</value>
</text>
<text>
<tabLabel>Address 2</tabLabel>
<value>Venice, CA 12345</value>
</text>
</textTabs>
<radioGroupTabs>
<radioGroup>
<groupName>Radio Group 1</groupName>
<radios>
<radio>
<selected>True</selected>
<value>Radio 1</value>
</radio>
<radio>
<selected>False</selected>
<value>Radio 2</value>
</radio>
</radios>
</radioGroup>
</radioGroupTabs>
</tabs>
</templateRole>
</templateRoles>
</envelopeDefinition>
Is this XML request correct? The 'Name' and 'Address *' tabs are correctly filled, but the radio group tabs are not filled at all.
Your XML looks correct to me; in fact, I was able to copy/paste (including the radioGroupTabs portion) from your code sample into my own request and it works as desired -- i.e., the radio button specified as selected in the request is indeed selected when the recipient opens the envelope.
I'd suggest you verify that the values of groupName and value (for each Radio) in the Request XML match exactly with the corresponding values specified for the Radio Button Tag Properties, as shown here in the DocuSign UI -- and keep in mind that values are case-sensitive:

print a page using xslt

How can print a page using xslt.
i need a link, or a button which when clicked invokes the print page printer dialog box.
I suspect you need to specify a bit more about what you are trying to do.
XSLT is simply a way to turn one block of text into another. The input is generally an xml buffer and the output is some text rendering of that buffer.
It is possible that you are trying to generate a script using XSLT and that you want that script to be able to open a print dialog when it is run by something e.g. you generate javascript, that then runs on a browser.
Can you describe in more detail what you want to achieve?
The following in an html page gives you a print link:
Print
XSLT is a language for transforming XML documents. That means you can add/modify content. Assuming your output is HTML, you can do this:
<xsl:template match="top">
<html>
<head>
</head>
<body>
<input name="print" type="button" value="Print"
onclick="javascript:window.print()">
<xsl:apply-templates />
</body>
</html>
</xsl:template>
But of course, where exactly the button has to go depends on your needs. I'd additionally, add a media=print specific CSS at the top so that the document comes out neat!