【问题标题】:URL Decode inside Lotusscript agent IBM DominoLotusscript 代理 IBM Domino 中的 URL 解码
【发布时间】:2014-06-10 16:48:17
【问题描述】:

我们如何对从 IBM Domino lotusscript 代理中的请求接收的文本进行 URL 解码?

【问题讨论】:

    标签: lotus-domino lotusscript agent urldecode


    【解决方案1】:

    一些简单的谷歌搜索显示了几个实现,例如这个:

    Function URLDecode(inpString As String) As String
       Dim temp As String
       Dim hexValue As String
       Dim ch As String
       Dim pos As Integer
       Dim newPos As Integer
       ' First, replace any plus signs with spaces
       temp = inpString
       While Instr(temp, "+") <> 0
          temp = Left(temp, Instr(temp, "+")-1) & " " & Mid(temp, Instr(temp, "+")+1)
       Wend
       ' Next, replace any "%x" encodings with the character
       pos = 1
       While Instr(pos, temp, "%x") <> 0
          hexValue = Mid(temp, Instr(pos, temp, "%x")+2, 2)
          ch = Chr$(Val("&H" & hexValue))
          newPos = Instr(pos, temp, "%x")+2
          temp = Left(temp, Instr(pos, temp, "%x")-1) & ch & Mid(temp, Instr(pos, temp, "%x")+4)
          pos = newPos
       Wend   
       ' Next, replace any "%u" encodings with the Unicode character
       pos = 1
       While Instr(pos, temp, "%u") <> 0
          hexValue = Mid(temp, Instr(pos, temp, "%u")+2, 4)    ' Unicode encodings are 4 hex characters
          ch = Uchr$(Val("&H" & hexValue))
          newPos = Instr(pos, temp, "%u")+2    ' Skip over so we don't find "%" if that's what it was decoded to
          temp = Left(temp, Instr(pos, temp, "%u")-1) & ch & Mid(temp, Instr(pos, temp, "%u")+6)
          pos = newPos
       Wend
       ' Next, replace any "%" encodings with the character
       pos = 1
       While Instr(pos, temp, "%") <> 0
          hexValue = Mid(temp, Instr(pos, temp, "%")+1, 2)
          ch = Chr$(Val("&H" & hexValue))
          newPos = Instr(pos, temp, "%")+1
          temp = Left(temp, Instr(pos, temp, "%")-1) & ch & Mid(temp, Instr(pos, temp, "%")+3)
          pos = newPos
       Wend
       URLDecode = temp
    End Function
    

    来源:http://www.breakingpar.com/bkp/home.nsf/0/830B9F6BB4A899AB87256AFB0014A04A

    【讨论】:

    • 我最好添加代码作为答案,以确保链接不会死,下次有人发现这个问题时......
    【解决方案2】:

    不幸的是,LotusScript 中没有默认的 URLdecode- 函数。我总是为此使用Evaluate

    Dim varResult as Variant
    Dim strUrl as String
    Dim strUrlDecoded as String
    
    strUrl = "Employee%2FMy%20Database.nsf"
    varResult = Evaluate( {@URLDecode( "Domino"; "} & strUrl & {" )} )
    strUrlDecoded = varResult( 0 )
    

    【讨论】:

      【解决方案3】:

      如果代理可以看到“CGI”字段(在 documentContext 上),则使用“QUERY_STRING_DECODED”字段,该字段将包含已解码的查询字符串!

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2017-12-07
        • 1970-01-01
        • 2015-12-31
        • 2012-11-08
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多