Post Reply 
funcRelativePathtoFull
Dec. 06, 2009, 08:18 PM
Post: #1
funcRelativePathtoFull
How about some light reading for the holidays. Wink
I think this works but I haven't really used it.

Have fun...

ReadMe.txt Wrote:Welcome,

funcRelativePathtoFull.zip contains ReadMe.txt, funcRelativePathtoFull.txt,
and funcRelativePathtoFull.cfg in funcRelativePathtoFull folder.
Scott R. Lemmon's Proxomitron Naoko 4.5 is required.

funcRelativePathtoFull.txt is a blocklist that attempts to provide a URL,
http://www.Shonen.Knife.com/spacebison.jpg, from a relative path,
../../../spacebison.jpg.

funcRelativePathtoFull.txt will only match if the optional variable
"verbose" is not empty!
Because funcRelativePathtoFull.txt may not match an expression like
($LST(funcRelativePathtoFull)|\w) may be required.

After funcRelativePathtoFull.txt has been called:
The variable xFP should contain the URL.
Values of \0 and \1 should be what they were before this list was called.

For your amusement,
funcRelativePathtoFull.cfg contains the commands to merge the blocklist
and two filters to play with.

Unzip funcRelativePathtoFull.zip
Add the funcRelativePathtoFull folder to the Proxomitron.exe's folder.
Open the Proxomitron's Merge-O-Matic dialog.
"Merge config filters" under "File" on the Proxomitron's main screen.
Make sure "Block Lists" and "Web Filters" are selected.
Navigate to "funcRelativePathtoFull.cfg" in the funcRelativePathtoFull folder.
"Open" "funcRelativePathtoFull.cfg".

More info in funcRelativePathtoFull.txt.
Some prior art is Mona's "ConvertRelativePath.cfg" at
http://tech.groups.yahoo.com/group/prox-...vePath.cfg

Have fun!

Code:
#$NoAddURL NoHASH $LST(funcRelativePathtoFull)
# Requires Scott R. Lemmon's Proxomitron Naoko 4.5
# December 06, 2009

# Attempts to provide a URL, http://www.Shonen.Knife.com/spacebison.jpg
# , from a relative path, ../../../spacebison.jpg .

# Match or no match:
# The variable xFP will contain the URL.
# Values of \0 and \1 will be what they were before this list was called, I hope.
# The variable xBase is an optional input. It could be the value of a Base tag.
# The variable verbose is an optional input.

# This list only matches when the variable verbose is not empty!
#  An expression like ($LST(funcRelativePathtoFull)|\w) may be required.


$TST(xBase=?*)$SET(Save1=\1)
    ( #    ($TST(xBase=([^#? ]+)\1$SET(xFP=\1#)(^))|)
    | \?   ($TST(xBase=([^#? ]+)\1$SET(xFP=\1?)(^))|)
    | //   $SET(xFP=http://)
    | /    ($TST(xBase=([^:]+://*/)\1$SET(xFP=\1)(^))|)
    | ../  $TST(xBase=((*/)++)\1[^/]+/[^/]+(^?))$SET(xFP=\1)
    (../  $TST(xFP=(*://[^/]+/(*/)++)\1[^/]+/[^/]+(^?))$SET(xFP=\1))+(../)+$SET(\1=$GET(Save1)$SET(Save1=))
    |(./|) ($TST(xBase=((*/)+)\1$SET(xFP=\1)(^))|)
    )
    ((\w)\0$SET(xFP=$GET(xFP)\0)(^)|\w)

$SET(Save1=\1)
    ( #    $SET(xFP=\u#)
    | \?   ($URL(([^:]+://)\1$SET(xFP=\1\h\p\?)(^))|)
    | //   $SET(xFP=http://)
    | /    ($URL(([^:]+://)\1$SET(xFP=\1\h/)(^))|)
    | ../  $URL(((*/)++)\1[^/]+/[^/]+(^?))$SET(xFP=\1)
    (../  $TST(xFP=(*://[^/]+/(*/)++)\1[^/]+/[^/]+(^?))$SET(xFP=\1))+(../)+$SET(\1=$GET(Save1)$SET(Save1=))
    |(./|) ($URL(((*/)+)\1$SET(xFP=\1)(^))|)
    )
    ((\w)\0$SET(xFP=$GET(xFP)\0)(^)|\w)


~(^$TST(verbose=?*))

# Some prior art is Mona's "ConvertRelativePath.cfg" at
#  http://tech.groups.yahoo.com/group/prox-list/files/Filters/_Other/ConvertRelativePath.cfg


# Examples
# HTML is         <a href="../../../spacebison.jpg">

# [Patterns]
# Name = "Using $LST(funcRelativePathtoFull) I"
# Active = FALSE
# URL = "$TYPE(htm)"
# Bounds = "<a href="(^http(s|)://)*>"
# Limit = 256
# Match = "\1=$AV($LST(funcRelativePathtoFull)|\w)\0"
# Replace = "\1="$GET(xFP)"\0$SET(xFP=)"

# Output would be    <a href="http://www.Shonen.Knife.com/spacebison.jpg">

# [Patterns]
# Name = "Using $LST(funcRelativePathtoFull) II"
# Active = FALSE
# URL = "$TYPE(htm)"
# Bounds = "<a href="(^http(s|)://)*>"
# Limit = 256
# Match = "*=$AV($LST(funcRelativePathtoFull)|$TST(xFP=http://www.Shonen.Knife.com/spacebison.jpg)\w)*"
# Replace = "<!- Proxo got it ->"

# Output would be     <!- Proxo got it ->

# The variables \0 and \1 are not harmed by calling this list.
#   Expressions like (\1$SET(a=\1)(^)|) do not change the value of \1
#     , because the side using \1 can never match.
#   Expressions that use \1 inside a loop may allow \1 to be reset
#     , $SET(\1=$GET(Save1)$SET(Save1=)).

#  Have fun.


Attached File(s)
.zip  funcRelativePathtoFull.zip (Size: 2.66 KB / Downloads: 559)
Add Thank You Quote this message in a reply
Post Reply 


Messages In This Thread
funcRelativePathtoFull - JJoe - Dec. 06, 2009 08:18 PM

Forum Jump: