Code download gives wrong filename

Discuss issues and requests related with the forum software
lexikos
Posts: 9621
Joined: 30 Sep 2013, 04:07
Contact:

Code download gives wrong filename

25 Jan 2015, 17:31

It appears that when there are multiple code blocks, the filename of the first one (if any) is used the download link downloads the first code block, even if that one doesn't have a download link. If I click the download link below, I get Untitled.txt (Test) on Chrome 42 and IE11:

Code: Select all

Test2

Code: Select all

Test
Manually adjusting the URL from part=1 to part=2 gives me the correct code block in this case.
User avatar
joedf
Posts: 8978
Joined: 29 Sep 2013, 17:08
Location: Canada
Contact:

Re: Code download gives wrong filename

25 Jan 2015, 19:47

Looks like TLM is working on it right now ;)
Image Image Image Image Image
Windows 10 x64 Professional, Intel i5-8500, NVIDIA GTX 1060 6GB, 2x16GB Kingston FURY Beast - DDR4 3200 MHz | [About Me] | [About the AHK Foundation] | [Courses on AutoHotkey]
[ASPDM - StdLib Distribution] | [Qonsole - Quake-like console emulator] | [LibCon - Autohotkey Console Library]
User avatar
TLM
Posts: 1608
Joined: 01 Oct 2013, 07:52
Contact:

Re: Code download gives wrong filename

25 Jan 2015, 20:49

Simplified some unnecessarily complicated preg.
Seems to be working.
User avatar
joedf
Posts: 8978
Joined: 29 Sep 2013, 17:08
Location: Canada
Contact:

Re: Code download gives wrong filename

25 Jan 2015, 23:53

great! what was the fix in general?
it would be great to know for future purposes. it happened to me once where i needed to know what i did before and luckily i had it posted somewhere.. ;)

Edit i think it was simply the regex going bezerk?

Code: Select all

// preg updated by TLM
	preg_match_all(	"#\s+file=(.*?):"
					. $post_data[$col_bbcode_uid] . "\](.*?)\[/code:"
					. $post_data[$col_bbcode_uid] . "\]#msi"
					, $post_data[$col_msg_text]
					, $code_data);
Image Image Image Image Image
Windows 10 x64 Professional, Intel i5-8500, NVIDIA GTX 1060 6GB, 2x16GB Kingston FURY Beast - DDR4 3200 MHz | [About Me] | [About the AHK Foundation] | [Courses on AutoHotkey]
[ASPDM - StdLib Distribution] | [Qonsole - Quake-like console emulator] | [LibCon - Autohotkey Console Library]
User avatar
TLM
Posts: 1608
Joined: 01 Oct 2013, 07:52
Contact:

Re: Code download gives wrong filename

26 Jan 2015, 01:59

I left a copy of the original preg above the update in the script plus a backup script appended with _ in the same dir :)

I used sample values returned for $post_data[$col_msg_text], extracted/substituted values/variables for $post_data[$col_bbcode_uid]
and tested the original capturing sub-pattern matches in $code_data[ 1 ][ 0 ] and $code_data[ 2 ][ 0 ].
Under the existing pattern, $code_data[ 2 ][ 0 ] didn't return anything ( when the code blocks are named as lexikos stated ), which was the issue.

I just simplified the approach of obtaining the capturing sub-pattern matches and stress tested it.
(wish there was an easier/cleaner way to debug though)
User avatar
joedf
Posts: 8978
Joined: 29 Sep 2013, 17:08
Location: Canada
Contact:

Re: Code download gives wrong filename

26 Jan 2015, 09:00

Nice! Yes I saw the console.log() haha, but anyhow it looks it sufficient ;)
Thanks for sharing, but I wonder why this happened now...
Image Image Image Image Image
Windows 10 x64 Professional, Intel i5-8500, NVIDIA GTX 1060 6GB, 2x16GB Kingston FURY Beast - DDR4 3200 MHz | [About Me] | [About the AHK Foundation] | [Courses on AutoHotkey]
[ASPDM - StdLib Distribution] | [Qonsole - Quake-like console emulator] | [LibCon - Autohotkey Console Library]

Return to “Forum Issues”

Who is online

Users browsing this forum: No registered users and 13 guests