Old Proxomitron Forums

Proxomitron Filters - Discussions welcome => Other => Topic started by: Jor on November 14, 2001, 11:59:49 AM

Title: Close Stylesheet comments
Post by: Jor on November 14, 2001, 11:59:49 AM
A little filter I wrote for use with Opera and some other browsers, that aren't as forgiving to unclosed comments in the head section:

----- start of filter -----

[Patterns]
Name = "Close stylesheet comments"
Active = FALSE
Limit = 256
Match = "(^ -->) & </style>"
Replace = "// --></style>"

----- end of filter -----

Specifically, this filter stops idiots that use a construct like
<html>
<head>
<style type=text/css>
<!--
[stylesheet]
</style>
</head>
The end result of this is a completely blank page in Opera and some other browsers, so enabling the filter while on these sites will make them visible. (So you can find the webmaster's address and yell at them through email

Of course it is possible to extend this filter by making it active always for certain sites, or for a blocklist of sites.

 
Title: Close Stylesheet comments
Post by: Jor on April 17, 2002, 12:08:47 PM
A somewhat better working version of this filter (thanks to altosax for the help):

Name = "Close stylesheet comments (1)"
Active = TRUE
Multi = TRUE
URL = "$TYPE(htm)"
Bounds = "$NEST(<style,</style>)"
Limit = 1500
Match = "1</style>"
        "&$SET(2=//-->)"
Replace = "12
"
          "</style>"

Name = "Close stylesheet comments (2)"
Active = TRUE
URL = "$TYPE(htm)"
Bounds = "$NEST(<style,</style>)"
Limit = 1500
Match = "1--> //-->
"
        "</style>"
Replace = "1 //-->
"
          "</style>"
Filter 1 adds the closing comment to all stylesheets, and filter 2 removes any doubles. (As this may cause problems with some sites). It's still far from perfect (The filter should only work if <!-- is present, but I haven't found a way to make that work yet), but it does the trick a lot better than the first version I posted.

Edited by - Jor on 26 Apr 2002  15:01:45
Title: Close Stylesheet comments
Post by: altosax on April 18, 2002, 02:28:57 PM

hi hpguru and jor.

i've fixed these filters, now they work fine.

btw, as usual, please test them yourself. if you confirm that they work, i'll upload them in the download sub-section of this forum, as requested by arne, to make them available to other users.

Name = "Close stylesheet comments"
Active = TRUE
URL = "$TYPE(htm)"
Bounds = "$NEST(<style,<style>)"
Limit = 12
Match = "(-->)1$STOP()|(</style>)2$SET(1=//-->)"
Replace = "1
2"

Name = "Add </head> tag when missing"
Active = TRUE
URL = "$TYPE(htm)"
Limit = 12
Match = "(</head>)1$STOP()|(<body)2$SET(1=</head>)"
Replace = "12"

NOTE: i've posted these filters in 2 different threads, the first started by hpguru, the second by jor.

regards,
altosax.


 
Title: Close Stylesheet comments
Post by: Jor on April 26, 2002, 02:00:28 PM
Altosax -- thanks for the help, the stylesheet filter still doesn't do what it's supposed to however.

I'm beginning to think doing it in one filter is impossible, so I'll continue using th two-filter method posted above instead. I've wasted enough time on this filter!

One change to these filters: the byte limit has to be increased. Largest inline CSS I encountered so far was 1478 chars... why they don't use an external stylesheet then is beyond my comprehension!

Edited by - Jor on 26 Apr 2002  15:02:40
Title: Close Stylesheet comments
Post by: altosax on April 26, 2002, 03:54:22 PM

hi jor,
i'm using IE and in my tests both filter work, but i know you use opera.
you could try these instead (i've only moved stop command):

Name = "Close stylesheet comments"
Active = TRUE
URL = "$TYPE(htm)"
Bounds = "$NEST(<style,<style>)"
Limit = 12
Match = "(-->)1|(</style>)2$SET(1=//-->)"
Replace = "1
2$STOP()"

Name = "Add </head> tag when missing"
Active = TRUE
URL = "$TYPE(htm)"
Limit = 12
Match = "(</head>)1|(<body)2$SET(1=</head>)"
Replace = "12$STOP()"

if it works, let me know.

regards,
altosax.


 
Title: Close Stylesheet comments
Post by: altosax on May 05, 2002, 05:29:51 PM

hi jor.

it was a hard work but finally i've reached the end =D
i've posted these two filters (the one you required and the one required by hpguru) in the same message because the trick they use is the same, so i've developed them at the same time.


Name = "Close stylesheet comments"      never worked this way ;)
Active = TRUE
URL = "$TYPE(htm)"
Bounds = "$NEST(<style,</style>)"
Limit = 2048
Match = "(-->*)1|(</style>)2$SET(1=//-->)"
Replace = "1
2"



Name = "Add </head> tag when missing"   improved to match also frameset
Active = TRUE
URL = "$TYPE(htm)"
Limit = 12
Match = "(</head>)1$STOP()|(<body|<frameset)2$SET(1=</head>)"
Replace = "12"


NOTE1: don't add "Multi = TRUE" otherwise the filter matches itself.
NOTE2: i've tried to test it on your test2 page, why you removed it?

regards,
altosax.

 
Title: Close Stylesheet comments
Post by: Jor on May 12, 2002, 11:59:54 PM
altosax -- thanks, the filter works perfectly (sorry for the late reply!)

I remove test pages all the time - a mistake on my part here.

Thank you very much for the help!