How to decode URL entities in iMacros URL extraction? - urlencode

I write some infos with the current URL into a csv-file with imacros. The URLs are written with
ADD !EXTRACT {{!URLCURRENT}}
SAVEAS TYPE=EXTRACT FOLDER=* FILE=+{{!NOW:ddmmyyyy}}.csv
After i open the csv file in Excel (open an empty Excel file, then import data from text (my csv) file) everything is OK, but if there are any entities in the URL, they are encoded like https://www.google.de/search?q=g%C3%83%C2%BCnstig%20%C3%83%C2%BCbernachten.
How can i adjust the iMacros code to write URLs and /or save the csv file with decoded URL entities?
I guess it could be possible to run something like decodeURIComponent or even something like this inside of iMacros, but don't know the right syntax for such implementations. My try to replace
ADD !EXTRACT {{!URLCURRENT}}
with
SET !VAR2 decodeURIComponent ({{!URLCURRENT}})
ADD !EXTRACT {{!VAR2}}
or
SET !VAR2 unescape ({{!URLCURRENT}})
ADD !EXTRACT {{!VAR2}}
don't work:(

This seems to work:
SET !EXTRACT {{!URLCURRENT}}
SET !EXTRACT EVAL("decodeURI('{{!EXTRACT}}');")
SAVEAS TYPE=EXTRACT FOLDER=* FILE=+{{!NOW:ddmmyyyy}}.csv
(However Microsoft Excel may not support UTF-8 encoding. So, open it with something like ‘Notepad’.)

Related

cfdirectory replacing spaces with + characters when action=list on an S3 folder

I am uploading a file, that contains spaces in the name, to Amazon S3 using cffile action="upload". The file name is burger+beans n beetroot.jpg.
As you can see, the name contains spaces and a plus sign.
When I read the directory, to list the contents, the file name returned by ColdFusion in the query is: burger+beans+n+beetroot.jpg. However, when viewing the file using Amazon S3 Browser, it is correctly listed as: burger+beans n beetroot.jpg. So it appears ColdFusion is replacing the spaces with + signs.
Does anyone know why this happens and if there is a way to disable this? I tried using both the DirectoryList() method as well as the <cfdirectory action="list"> tag, and both do this.
Please note: I am aware that the file name could be cleaned up before processing - that's a workaround, but not the solution I am looking for. Thanks!
I believe this is not a CF problem, it's a S3 problem. They send out their file names escaped. Which makes this a non-answer.
I created a folder in a S3 bucket. Then I uploaded a file named burger+beans n beetroot.jpg. I can see in AWS' console the file properly named. I select it, then in the Actions menu select Download. I get the modal window. Take a look at the URL in the browser footer - the file name is escaped.
I right-click their link and choose "Save Link As..." - the file name is escaped as well.
So I don't think there is anything you can do once the file is up there. You'll need to clean it before uploading. I know it's not what you want to hear.
Try URL encoding the filename, so the + sign will be converted to an url encoded space (%2b). You could use URLEncodedFormat, but make sure that the path to the file isn't urlencoded as well.

Upload csv files with comma inside it

As per my requirement, I need to upload a .csv file into the application. I am trying to simulate this using loadrunner. The issue I am encoutering is that my csv file is in the below format
Header - AA,BB,CC
Data-xyz,"yyx,zzy",xxz
On using the below statement to upload the file, I am getting an error ""line 2 contains 4 columns instead of 3"
web_submit_data("upload",
"Action=xxx/upload",
"Method=POST",
"EncType=multipart/form-data",
"RecContentType=text/html",
"Referer=xxx",
"Snapshot=t86.inf",
"Mode=HTML",
ITEMDATA,
"Name=utf8", "Value=✓", ENDITEM,
"Name=token", "Value={token_1}", ENDITEM,
"Name=upload_file", "Value={NewParam_5}", "File=yes", "ContentType=text/csv", ENDITEM,
"Name=Button1", "Value=Upload", ENDITEM,
LAST);
AS per information provided in How to deal with a string with comma in it from a csv, when we have to read the data by using loadrunner? ,
I tried updating the .prm file to a new delimiter pipe, | but still i get the error.
[parameter:NewParam_5]
Delimiter="|"
ParamName="NewParam_5"
TableLocation="C:\temp"
ColumnName="Col 1"
I also notice that even though I set the delimiter to pipe, if I rightclick on the web_submit_data() and go to Parameter properties, i see a column delimiter option there as well and it is not set to pipe and is set to comma which indicates that this setting is taking higher precedence to the setting in .prm file.
Can someone please guide me the right way to set a new delimiter so that vugen recognizes and parses the csv file as I want it to.
I am using loadrunner 12.5
Thanks for your help.
Do you need to upload a file or a line of comma separated variables? Right now you appear to be reading a line of CSV variables, not a file as your parameter file would contain a list of filenames or a single file reference within the directory of the virtual user (extra files, transferred with the use) or created by the virtual user and then uploaded.

nodejs npm libraries to access and modify microsoft word documents

Do you know if it is possible to search specific text like "xAx" into a Microsoft Word file (.doc or .docx) hosted on a website, replace it with some other text input by the user and make the file available for download using nodejs?
Is there a npm library that can do that?
If not it is possible to manipulate a PDF file instead? Please note that I do not want to create the document but manipulate a template file in the server.
Thank you for your help.
There is project https://github.com/open-xml-templating/docxtemplater which serves for replacing {placeholders} in a .docx files.
Also supports loops and images, check out demo (examples) on http://javascript-ninja.fr/docxtemplater/v1/examples/demo.html
If odt is an option (these files are open directly by MS Word besides Open and Libre Office and can be set with extension .doc so end users do not freak out) you can use HTML52PDF.
For example something like the following code will replace a string of text by a link:
require_once 'path/to/CreateDocument.inc';
$doc = new Html52pdf\createDocument(array('template' => 'template.odt'));
$format = '.odt';//.pdf, .doc, .docx, .odt, .rtf
//replace natural text
$doc->replace(array('replace me, please' => array('value' => 'external link')), array('format' => array('','')));
$doc->render('replaced_content' . $format);

How do I append to end of a file, without deleting its previous content, in eiffel

i am programming with eiffel and every time i open a file and start writing into it, it deletes its content and starts writing into it like it's an empty file, is there a way to do it without deleting the previouse content?
Here is a example of code
local
f: PLAIN_TEXT_FILE
do
create f.make_open_write("C://myName/desktop//myfile.txt")
f.put_integer(3)
and now the file will contain 3 and all the previouse data will be lost!
Creation procedure make_open_append should be used in this case:
create f.make_open_append ("C:/myName/desktop/myfile.txt")
f.put_integer(3)
If you want to append text at the end of the file, use make_open_append like that:
f.make_open_append("C://myName/desktop//myfile.txt")
If you want to rewrite from the beginning of the file (like in your example, replacing the first character of the file with 3), you can open in read write mode and write to it like this:
f.make_open_read_write("C://myName/desktop//myfile.txt")
f.put_integer(3)

How can I determine if a file upload is a valid CSV file - or at least text - in ColdFusion 8?

I have a form which allows a user to upload a file to the server. How can I validate that the uploaded file is in fact the expected format (CSV, or at least validate that it is a text file) in ColdFusion 8?
For simple formats like CSV, just check yourself, for example via regex.
<cffile action="read" file="#uploadedFile#" variable="contents" charset="UTF-8">
<cfset LooksLikeCSV = REFind("^([^;]*;)+[^;]*$", contents)>
You can place additional checks with regard to file size limits or forbidden characters.
For other file formats, you can check for header signatures that occur in the first few bytes of the file.
You could even write a full parser for your expected file format - for CSV validation, you could do a ListToArray() at CR/LF and check each line individually against a regex. XML should work pretty straightforward as well - just try to pass it to XmlParse(). Binary formats like images are a little more difficult, but libraries exist there as well.
I dont know if it can help you but Ben Nadel wrote excellents posts about CSV:
http://www.bennadel.com/blog/483-Parsing-CSV-Data-Using-ColdFusion.htm
http://www.bennadel.com/blog/976-Regular-Expressions-Make-CSV-Parsing-In-ColdFusion-So-Much-Easier-And-Faster-.htm
http://www.bennadel.com/blog/501-Parsing-CSV-Values-In-To-A-ColdFusion-Query.htm
I think it's as simple as specifying the accept value in cffile ...Unfortunately the CF8 docs don't specify the value as part of the info for cffile ... It's under file management ...
<cffile action=”upload” filefield=”filename” destination=”#destination#” accept=”text/csv”>
CF8 » Controlling the type of file uploaded