Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Where is Safari's Safe File List stored - Mac OS X 10.9.3

Title says it all really. I have written a script to convert QIF field to OFX files when down loaded from my on-line banking and would like the file to open on downloading in the QIF2OFXV2 script.


Many thanks in advance.

Posted on Jul 5, 2014 5:21 AM

Reply
6 replies

Jul 5, 2014 6:13 AM in response to cdlane

I'd argue that there are no safe file formats. That it is best to assume they're all hostile, and to reset that "safe" default to be "no; please don't automatically launch that drive-by attack against my system".


Background: There are a number of proof-of-concept files that combine valid PDF files and other file formats, and combine GIF and Java jar files, and other mixtures, too — this whole area is getting rather nasty to defend against. There are also so-called "drive-by downloads" that have occasionally hit OS X browsers, too.


If that sort of attack doesn't concern you here, then please start reading here for a discussion of the "safe" file list management. That's a little old, but that plist is still around on Mavericks.


I'd probably look at some way to access the data from the banking site (via HTTPS) more directly if that's feasible here, and not by a scripted download that automatically opens the file — if the download is the only way, I'd either use a different browser for the download and keep the automatic open disabled in your main browser, or would toggle that automatic-open setting around this particular download. I'd try to keep that feature disabled whenever possible.

Jul 5, 2014 6:23 AM in response to MrHoffman

Many thanks for the quick response :-) The file is manually downloaded from a clearing banks https site, the download isn't automated. My aim is to have the QIF file open automatically, in QIF2OFXV2 and not in MoneyDance (my personal fiancé software de choix) and convert to a OFX format. The script then opens MoneyDance and imports the newly converted file. As for direct access to the data, no banks in the UK support background banking anymore, which is a great shame from my point of view.


I'll let you know how I get on.


Best regards,


Chris

Jul 5, 2014 8:33 AM in response to MrHoffman

The download is done manually from within the online banking i.e. click "Download" to download the statement file. However the folder option s an excellent suggestion and one I'd overlooked :-) I'll have a play now.


For anyone finding this when looking for QIF to OFX conversion on google here is the script below. Use as you wish, if it breaks anything, it's not my fault ;-) Can be tweaked to prompt for file to open. I can't get the formatting right here...but you get the general gist.


on open TheDroppedFile


--set QIFstr to "Please locate your CSV file..."

--set QIF_File to (choose file with prompt QIFstr) as text


-- save ApplesScripts delimiters current state and setup variables

set Old_Delims to AppleScript's text item delimiters

set Save_Date to "00-00-00"

set OFX_Data to null

set OFX_Data1 to null

set OFX_Data2 to null

set OFX_Data3 to null

set FITID_Data to null


--Extracting the account number from the source file name NOTE This is dependant on the naming convention used by your bank

set QIF_File to TheDroppedFile as text

set Acct_Num to text ((offset of "_" in QIF_File) + 1) thru ((offset of "_" in QIF_File) + 8) of QIF_File


-- Set the file to write to

set OFX_File to (open for access file (((path to desktop) as string) & Acct_Num & ".ofx") with write permission)


-- write header concat file name with header record

set OFX_Header to "OFXHEADER:100

DATA:OFXSGML

VERSION:102

SECURITY:NONE

ENCODING:USASCII

CHARSET:1252

COMPRESSION:NONE

OLDFILEUID:NONE

NEWFILEUID:NONE



<OFX>

<SIGNONMSGSRSV1>

<SONRS>

<STATUS>

<CODE>0

<SEVERITY>INFO

</STATUS>

<DTSERVER>20991231000000[-5:EST]

<LANGUAGE>ENG

</SONRS>

</SIGNONMSGSRSV1>

<BANKMSGSRSV1>

<STMTTRNRS>

<TRNUID>1

<STATUS>

<CODE>0

<SEVERITY>INFO

</STATUS>

<STMTRS>

<CURDEF>GBP

<BANKACCTFROM>

<BANKID>999999

<ACCTID>" & Acct_Num & "

<ACCTTYPE>CHECKING

</BANKACCTFROM>

<BANKTRANLIST>

<DTSTART>20000101000000[-5:EST]

<DTEND>20991231000000[-5:EST]

" as string


write (OFX_Header) to OFX_File starting at eof


-- Reading your file in to memory

set QIF_Records to paragraphs of (read file QIF_File)




-- Read through records and write out correct OFX standard

repeat with i in QIF_Records


-- Check for EOF NOTE: This is dependent on how your bank ends the file

-- if (offset of "^" in i) = 1 and length of i = 1 then

-- exit repeat

-- end if


-- Create DTPOSTED records

if (offset of "D" in i) = 1 and length of i > 1 then

set OFX_Data1 to "<DTPOSTED>" & "20" & (text 8 thru 9 of i) & (text 2 thru 3 of i) & (text 5 thru 6 of i) & "000000[-5:EST]"

end if


-- Create FTID record from DTPOSTED date and increment counter by 1 padded with zeros

if (offset of "D" in i) = 1 then

if Save_Date = (text 2 thru 9 of i) then

set FT_ID to FT_ID + 1

else

set Save_Date to (text 2 thru 9 of i)

set FT_ID to 1

end if

set FITID_Data to "<FITID>+" & "20" & (text 8 thru 9 of i) & (text 2 thru 3 of i) & (text 5 thru 6 of i) & add_leading_zeros(FT_ID, 5)

end if


-- Set TRNTYPE to PAYMENT or OTHER depending upon sign

if (offset of "T" in i) = 1 then

if (offset of "-" in i) = 2 then

set OFX_Data1 to "<STMTTRN>" & return & "<TRNTYPE>PAYMENT" & return & OFX_Data1

else

set OFX_Data1 to "<STMTTRN>" & return & "<TRNTYPE>OTHER" & return & OFX_Data1

end if

-- Check length of transaction amount text and strip out , if present

if i contains "," then

set AppleScript's text item delimiters to {","}

set Delimited_List to every text item of i

set AppleScript's text item delimiters to {""}

set i to Delimited_List as string

set AppleScript's text item delimiters to Old_Delims

end if

set OFX_Data2 to "<TRNAMT>" & (text 2 thru (length of i) of i)

end if


-- Check length of text transaction description text and strip out & if present and prior to position 29

if (offset of "P" in i) = 1 then


-- if length of i < 34 then

set Tran_Desc_Length to length of i

-- else

-- set Tran_Desc_Length to 33

-- end if


-- if i contains "&" then

-- if (offset of "&" in i) < 30 then

-- set AppleScript's text item delimiters to {"&"}

-- set Delimited_List to every text item of i

-- set AppleScript's text item delimiters to {"&amp;"}

-- set i to Delimited_List as string

-- set AppleScript's text item delimiters to Old_Delims

-- else

-- set Tran_Desc_Length to (offset of "&" in i) - 1

-- end if

-- end if


set OFX_Data3 to "<NAME>" & (text 2 thru Tran_Desc_Length of i) & return & "</STMTTRN>"


end if


if not (OFX_Data1 = null or OFX_Data2 = null or FITID_Data = null or OFX_Data3 = null) then

set OFX_Data to OFX_Data1 & return & OFX_Data2 & return & FITID_Data & return & OFX_Data3 & return

write (OFX_Data) to OFX_File

set OFX_Data to null

set OFX_Data1 to null

set OFX_Data2 to null

set OFX_Data3 to null

set FITID_Data to null

end if


end repeat


set OFX_Footer to "</BANKTRANLIST>

<LEDGERBAL>

<BALAMT>00.00

<DTASOF>20991231000000[-5:EST]

</LEDGERBAL>

</STMTRS>

</STMTTRNRS>

</BANKMSGSRSV1>

</OFX>" as string


write (OFX_Footer) to OFX_File starting at eof


set AppleScript's text item delimiters to Old_Delims


do shell script "rm " & quoted form of the POSIX path of QIF_File


tell application "Finder"

--activate

open file (((path to desktop) as string) & Acct_Num & ".ofx")


set Del_OFX_Output to button returned of (display dialog "Would you like to delete the output file now?" buttons {"No", "Yes"} default button "Yes")

if Del_OFX_Output is "Yes" then

delete file (((path to desktop) as string) & Acct_Num & ".ofx")

end if


end tell


end open



on add_leading_zeros(This_Number, Max_Leading_Zeros)

set the Threshold_Number to (10 ^ Max_Leading_Zeros) as integer

if This_Number is less than the Threshold_Number then

set the Leading_Zeros to ""

set the Digit_Count to the length of ((This_Number div 1) as string)

set the Character_Count to (Max_Leading_Zeros + 1) - Digit_Count

repeat Character_Count times

set the Leading_Zeros to (the Leading_Zeros & "0") as string

end repeat

return (Leading_Zeros & (This_Number as text)) as string

else

return This_Number as text

end if

end add_leading_zeros

Apr 26, 2015 2:23 PM in response to MrHoffman

MrHoffman wrote:


please start reading here for a discussion of the "safe" file list management. That's a little old, but that plist is still around on Mavericks.


That hint listed at http://mymacinations.com/2008/02/06/changing-the-systems-default-settings-for-ht ml-files-safe/ includes the following note:


Update 2011-08-01: Safari 5.1.0 Ignores com.apple.DownloadAssessment.plist.


and presumably subsequent Safari releases don't acknowledge this whitelist either; I couldn't get it to work on Safari 7.1.5 under Mavericks 10.9.5.

Where is Safari's Safe File List stored - Mac OS X 10.9.3

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.