Print Story A note to myself in the future
Scoop
By hulver (Sun Feb 05, 2006 at 05:26:11 AM EST) scoop, perl, security (all tags)
And to anybody else wondering why you can't pass parameters to boxes in a macro.

I had forgotten why, I just knew there was a good reason why you couldn't.

I've just tried to do it again, and worked out why you can't do it.



So, if you wanted to set up the parameters first like sugested in this story. It sounds like a good idea.

It would turn the file macro from something that returns ((1)),((2)) into something that gets passed the parameters to process.

This would make the box code look like

$img = $ARGS[0];
$desc = $ARGS[1];

etc.

However, look at this bit of code.

$macro_text = $S->interpolate($macro_text,$S->{UI}->{BLOCKS},{special=>'true'});
$macro_text = $S->interpolate($macro_text,$S->{UI}->{VARS},{clear => 'true'});

For a macro like "((*file [2/myimage.jpg] [My goatse impression]))"

So instead of passing %%BOX,show_images_extra%% to interpolate, we'd be passing
%%BOX,show_images_extra,2/myimage.jpg,My goatse impression%%

However, say I made up a macro like.

((*file [%% %%BOX,delete_story,*%%] [Bye bye]))

This would make the text passed through to interpolate be

%%BOX,show_images_extra,%% %%BOX,delete_story,*%%, Bye bye%%

Sure, we could filter out "%%" from the arguments. But then we'd also have to filter out commas "," as well. As they are the box parameters seperator.

All this for something you might not even be passing through to a box anyway.

Now, I'm sure I might be able to think up a solution to this, but if anybody has got any ideas I'd love to hear them.

This is mainly for me, because I keep forgetting the reasons for not doing this in the first place.

Update [2006-2-5 16:19:11 by hulver]: Of course, I'm an idiot. I should just make sure that the relavent offending characters are no longer there, and it'll just work.

The upshot of that is that I no longer need to do a global ' > ' replacement. So, spoiler macros with ' in will work correctly now. &qout; still won't work though.

< "Passionate and Reasonable... I Hope!" | BBC White season: 'Rivers of Blood' >
A note to myself in the future | 7 comments (7 topical, 0 hidden) | Trackback
My brain is at half-speed today by gazbo (2.00 / 0) #1 Sun Feb 05, 2006 at 05:41:14 AM EST
But are you saying that the only problem with enabling params to be passed is that you'd have to filter out %% and commas, thus meaning you couldn't use commas in, say, the alt tag?

If that is what you're saying, couldn't you just replace commas with ,?  That should work fine in all but the most esoteric of cases, as the browser should parse the entity even if it's used in a link, or as alt text or whatever.  So unless the box is actually parsing for a comma in the parameter itself, it seems like it should work fine.


I recommend always assuming 7th normal form where items in a text column are not allowed to rhyme.

*sigh*, that was monumentally stupid: by gazbo (2.00 / 0) #2 Sun Feb 05, 2006 at 05:42:33 AM EST
couldn't you just replace commas with ,?

I mean, of course, "replace it with &#44;"


I recommend always assuming 7th normal form where items in a text column are not allowed to rhyme.

[ Parent ]
I thought it made sense. by ambrosen (2.00 / 0) #3 Sun Feb 05, 2006 at 05:58:58 AM EST
Although I was wondering what kind of illogical escape character scheme would print something verbatim if followed by a question mark.

[ Parent ]
..what kind of illogical escape character scheme.. by gazbo (4.00 / 1) #4 Sun Feb 05, 2006 at 06:07:25 AM EST
THE VERY BEST KIND.

I recommend always assuming 7th normal form where items in a text column are not allowed to rhyme.

[ Parent ]
Even better than? by ambrosen (2.00 / 0) #5 Sun Feb 05, 2006 at 06:22:26 AM EST
The HTML comment end system? (-- for those in the know)

[ Parent ]
Ah, by ambrosen (4.00 / 1) #6 Sun Feb 05, 2006 at 06:26:38 AM EST
I see hulver fixed that one, anyway.

[ Parent ]
Yes by hulver (2.00 / 0) #7 Sun Feb 05, 2006 at 08:56:39 AM EST
Pretty much.

As I was posting this whole diary I thought "It can't be as simple as just replacing % and , can it?"

It looks like it is.
--
Cheese is not a hat. - clock

[ Parent ]
A note to myself in the future | 7 comments (7 topical, 0 hidden) | Trackback