why $this->input->post(NULL,TRUE) don't escape html tags ?
is there any hook to replace < character with empty in codeigniter?
Related
I'm trying to place some whitespace at the start of a string, like so:
- sbSecId: 4
title: ' VideoJS'
link: /examples/video/instream/videojs/pb-ve-videojs.html
isLastSubSectionItem: 0
isHeader: 0
isSectionHeader: 0
sectionTitle:
subgroup: 1
this is for a site being generated by Jekyll. I'm using Liquid to make an array of the yml file, looping through the array and displaying the title key's value like so:
{{thisSubItem.title}}
despite having the key value in quotes the whitespace is being deleted. Is this a Jekyll thing? How can I get the whitespace to be retained?
This is not a Jekyll thing this html that strips unnecessary spaces.
Here you can use CSS rule
<span style="white-space: pre;">{{thisSubItem.title}}</span>
Or by replacing spaces by non-breaking spaces
{% assign preserved_ws = thisSubItem.title | replace: " ", " " %}
{{ preserved_ws }}
Nevertheless, if it's only a presentation matter, you must get rid of spaces and go with CSS margins.
Instead, you could leave the spaces out of the string and have it in the layout or wherever the value is being rendered. You could remove the whitespace from the string and wouldn't need to worry about remembering to keep the whitespace consistent.
{{thisSubItem.title}}
I've been working with Nokogiri for a couple of days and I absolutely adore it. Everything was working brilliantly until I got a requirement to scrape a website that uses the data-reactid javascript attribute tag. The problem is that Nokogiri seems to be getting confused with the attribute id format this website is using (several periods, some dollar signs and some other invalid xml/css characters):
An example of what I need to scrape would be:
<td data-reactid=".3.3.1:$contract_23.$=1$dataRow:0.1">94.280</td>
I need the value (94.280) inside of the attribute with an id of ".3.3.1:$contract_23.$=1$dataRow:0.1"
which usually in nokogiri we would select by doing something like:
doc.css("type[attributename=attributeid]")
in my example it would be:
doc.css("td[data-reactid=.3.3.1:$contract_23.$=1$dataRow:0.1]")
but no matter what I do to escape the invalid characters, it keeps telling me there is an invalid character after my equals sign:
Error message for code above:
nokogiri-1.4.3.1/lib/nokogiri/css/parser.rb:78:in `on_error': unexpected '.3' after 'equal'
I've tried:
a) Getting my string defined as a variable and forced into a string
b) Escaping it with backslashes (.3.[...])
c) Prefixing it with a hash (#.3.3[...])
d) Escaping it using cgi escapedString
e) Placing it inside '%{ }' eg '%{.3.3[...]}'
No matter what I do, I keep getting the same message (except for option e which gives me an altogether different error message:
: no .<digit> floating literal anymore; put 0 before dot
Can you guys help me get the right value with such an oddly-named attribute?
You didn't show how you are parsing your document, but if I parse it as HTML and then use single quotes around the attribute value in the css selector, I can get the tag:
require 'nokogiri'
html = <<END_OF_HTML
<td data-reactid="hello">10</td>
<td data-reactid=".3.3.1:$contract_23.$=1$dataRow:0.1">94.280</td>
<td data-reactid="goodbye">20</td>
END_OF_HTML
html_doc = Nokogiri::HTML(html)
html_doc.css("td[data-reactid='.3.3.1:$contract_23.$=1$dataRow:0.1']").each do |tag|
puts tag.text
end
--output:--
94.280
Check out the Mothereffing Unquoted Attribute Value Validator via this SO post:
CSS attribute selectors: The rules on quotes (", ' or none?)
If I have a string that is this
<f = x1106f='0'>something
and The values inside <> can change How would I use regular expressions to isolate "something" and replace the tag?
EDIT:
<(.*?)> Pattern worked
What you need is
string =~ />([^<]+)/
and the something will be captured in $1.
Use the following regex to capture "something":
(?<=>)(.*?)(?=<)
assuming that after "something" there's a closing tag.
Link to fiddle
Here is the data that I need to parse them as CSV.
Actually, I am making CSV string which I will need to import to another system.
Basically, I append comma between each field that I query from DB.
Column1 :
Testing
Column 2:
<p class="MsoNormal" style=""><b><span style="font-size: 10.0pt; ">This is just a test, test2, test3</span></b><span style="font-size: 10.0pt; "></span></p>
Column 3:
Blah Blah
Now, I am facing problem of retaining double quotes and comma (as I need to save as in HTML format of this text).
I try to append double quote for for the column2 data at the start and end, but it doesn't work out.
Any suggestion for this?
String has the instance method escapeCSV, this should be what you need.
If you need something different you could always use replace to replace any characters you want to escape with escapeCharacter+originalCharacter eg. (" => \").
I use a WYSIWIG html component to allow my customers to enter html content and I clean it up on the server side using JSoup. Sometimes (depending on the browser and the user), the content that gets submitted contains empty tags (like <p>), or whitespace tags (like <br />). These are annoying since for all intents and purposes the input is blank, but the length of the string is non-zero.
Does anyone know if there is a JSoup setting that allows me chomp off all trailing tags that contain no content?
Jsoup's getText() method may help you.
if < div class="data">
< br >MY Name is < /br >
< br>Chirag< /br>
< br> < / br>
< /div>
than Elements data=doc.getElementsByClass("data") ,data.getText() gives you "My Name is Chirag" .