Skip to content

Commit

Permalink
Fix SannerFacade#findScriptUrl to extract only the src attribute string
Browse files Browse the repository at this point in the history
  • Loading branch information
MasanoriOnuki committed Jun 14, 2024
1 parent a8069dd commit b8a2948
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,15 @@ private List<String> findScriptUrl(String source) {
Pattern p = Pattern.compile(
"<script[^>]*" + //script tags
"src=" + //src attribute
"[\"']([^>]*)[\"']", //URL between quotes
"(?<src>\"[^\"]*?\"|'[^']*?'|\\S+)", //URL between quotes
Pattern.CASE_INSENSITIVE);

Matcher m = p.matcher(line);
if(m.find()) {
String urlScript = m.group(1);
if (m.find()) {
String src = m.group("src");
String urlScript = src.startsWith("\"") || src.startsWith("'")
? src.substring(1, src.length() - 1) // trim quotes
: src;
urls.add(urlScript);
}
}
Expand Down

0 comments on commit b8a2948

Please sign in to comment.