Skip to content

Commit e605fc7

Browse files
committed
Detect already escaped ampersands
1 parent 25173fe commit e605fc7

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/xml_security.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def validate_doc(base64_cert, soft = true)
9090

9191
hashed_element = document.at_xpath("//*[@ID='#{uri[1..-1]}']")
9292
canon_algorithm = canon_algorithm REXML::XPath.first(ref, '//ds:CanonicalizationMethod', 'ds' => DSIG)
93-
canon_hashed_element = hashed_element.canonicalize(canon_algorithm, inclusive_namespaces).gsub('&','&')
93+
canon_hashed_element = hashed_element.canonicalize(canon_algorithm, inclusive_namespaces).gsub(/&(?!amp;)/,'&')
9494

9595
digest_algorithm = algorithm(REXML::XPath.first(ref, "//ds:DigestMethod"))
9696

0 commit comments

Comments
 (0)