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

Popular posts from this blog

django - How can I change user group without delete record -

java - Need to add SOAP security token -

java - EclipseLink JPA Object is not a known entity type -