Skip to content

Commit 8a99308

Browse files
committed
Merge pull request #59 from assaydepot/fix_amp_regex
Detect already escaped ampersands
2 parents 37547a8 + e605fc7 commit 8a99308

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
@@ -94,7 +94,7 @@ def validate_doc(base64_cert, soft = true)
9494

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

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

0 commit comments

Comments
 (0)