python - Why do errors occur? -
simply source
class page: pages = "/.././ewcwe/../qds/./qwd/qwf/qwd/../../../sad/qwd/../sad/qwd/sad/.././../../../../bbs/./board.php?bo_table=humor&wr_id=195?los=09&qwe=2&" def __init__(self): self.normalize() def normalize(self): j in range(1, len(self.pages)): if self.pages[j-1] != "." , self.pages[j] == "." , self.pages[j+1] == "/": self.pages = self.pages[:j] + self.pages[j+2:] print self.pages print self.pages index = page()
there's no problem error occurs. why errors occur?
import os os.path.normpath(pages)
normalizes path , returns:
'/bbs/board.php?bo_table=humor&wr_id=195?los=09&qwe=2&'
you don't have reinvent wheel.
Comments
Post a Comment