Skip to content

Commit 7f6963a

Browse files
author
updating-bot
committed
mirroring bot - 2025/09/05
1 parent b471742 commit 7f6963a

19 files changed

+655
-411
lines changed

svn_browser/src/jd/http/Browser.java

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -640,7 +640,7 @@ private static void waitForPageAccess(final Browser browser, final Request reque
640640
private String acceptLanguage = "de, en-gb;q=0.9, en;q=0.8";
641641
/*
642642
* -1 means use default Timeouts
643-
*
643+
*
644644
* 0 means infinite (DO NOT USE if not needed)
645645
*/
646646
private int connectTimeout = -1;
@@ -2995,6 +2995,43 @@ public Boolean prepareBlockDetection(Browser browser, Request request) {
29952995
return null;
29962996
}
29972997
},
2998+
FORTINET_SECURE_DNS {
2999+
@Override
3000+
public String getLabel() {
3001+
return "DNS blocked by Fortinet Secure";
3002+
}
3003+
3004+
@Override
3005+
public BlockedTypeInterface isBlocked(Browser browser, Request request) {
3006+
final HTTPConnection con;
3007+
if (request == null || !request.isLoaded() || (con = request.getHttpConnection()) == null) {
3008+
return null;
3009+
} else if (con.getResponseCode() == 403) {
3010+
// <title>Fortinet Secure DNS Service Portal</title>
3011+
// <h2>Web Page Blocked!</h2>
3012+
// You have tried to access a web page which belongs to a category that is blocked.
3013+
if (request.containsHTML("<title>\\s*Fortinet Secure DNS Service Portal\\s*</title>") && request.containsHTML(">\\s*Web Page Blocked!\\s*<")) {
3014+
return this;
3015+
}
3016+
}
3017+
return null;
3018+
}
3019+
3020+
@Override
3021+
public BlockLevelType getBlockLevelType() {
3022+
return BlockLevelType.DNS;
3023+
}
3024+
3025+
@Override
3026+
public BlockSourceType getBlockSourceType() {
3027+
return BlockSourceType.SERVICE;
3028+
}
3029+
3030+
@Override
3031+
public Boolean prepareBlockDetection(Browser browser, Request request) {
3032+
return null;
3033+
}
3034+
},
29983035
CLOUDFILT {
29993036
@Override
30003037
public String getLabel() {

svn_trunk/src/jd/controlling/linkcrawler/CrawledLink.java

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ public CrawledLink(CharSequence url) {
296296
}
297297

298298
public String getName() {
299-
final String lname = name;
299+
final String lname = _getName();
300300
if (lname != null) {
301301
if (lname.contains("<jd:")) {
302302
final CrawledPackage lparent = this.getParentNode();
@@ -340,15 +340,16 @@ public void setChunks(int chunks) {
340340
}
341341

342342
public void setName(String name) {
343-
if (StringUtils.equals(name, this.name)) {
343+
final String crawledLinkName = _getName();
344+
if (StringUtils.equals(name, crawledLinkName)) {
344345
return;
345346
}
346347
final DownloadLink link = getDownloadLink();
347348
if (link != null) {
348349
if (StringUtils.equals(name, link.getName())) {
349350
name = null;
350351
}
351-
if (StringUtils.equals(name, this.name)) {
352+
if (StringUtils.equals(name, crawledLinkName)) {
352353
return;
353354
}
354355
}
@@ -357,7 +358,7 @@ public void setName(String name) {
357358
// see getName method
358359
name = fixFilename(name);
359360
}
360-
if (StringUtils.equals(name, this.name)) {
361+
if (StringUtils.equals(name, crawledLinkName)) {
361362
return;
362363
}
363364
}
@@ -376,13 +377,31 @@ protected String fixFilename(final String filename) {
376377
return LinknameCleaner.cleanFilename(filename);
377378
}
378379

380+
public static String getForcedName(final DownloadLink downloadLink) {
381+
final AbstractNodeNotifier nodeChangeListener = downloadLink.getNodeChangeListener();
382+
if (nodeChangeListener instanceof CrawledLink) {
383+
// DownloadLink is attached to a CrawledLink, get forced name of CrawledLink
384+
return ((CrawledLink) nodeChangeListener)._getName();
385+
}
386+
return downloadLink.getForcedFileName();
387+
}
388+
389+
public static void setForcedName(final DownloadLink downloadLink, final String forcedName) {
390+
downloadLink.setForcedFileName(forcedName);
391+
final AbstractNodeNotifier nodeChangeListener = downloadLink.getNodeChangeListener();
392+
if (nodeChangeListener instanceof CrawledLink) {
393+
// DownloadLink is attached to a CrawledLink, get forced name of CrawledLink
394+
((CrawledLink) nodeChangeListener).setName(forcedName);
395+
}
396+
}
397+
379398
/* returns unmodified name variable */
380399
public String _getName() {
381400
return name;
382401
}
383402

384403
public boolean isNameSet() {
385-
return name != null;
404+
return _getName() != null;
386405
}
387406

388407
public String getHost() {

svn_trunk/src/jd/plugins/DownloadLink.java

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -765,7 +765,7 @@ public void setInternalTmpFilename(String fileName) {
765765
fileName = this.fixFilename(fileName);
766766
this.setProperty(PROPERTY_CUSTOM_LOCALFILENAME, fileName);
767767
}
768-
cachedName = null;
768+
clearNameCache();
769769
}
770770

771771
/**
@@ -780,7 +780,7 @@ public void setInternalTmpFilenameAppend(String fileName) {
780780
fileName = this.fixFilename(fileName);
781781
this.setProperty(PROPERTY_CUSTOM_LOCALFILENAMEAPPEND, fileName);
782782
}
783-
cachedName = null;
783+
clearNameCache();
784784
}
785785

786786
/**
@@ -1510,7 +1510,7 @@ public void setName(String name) {
15101510
name = UNKNOWN_FILE_NAME;
15111511
}
15121512
this.name = name;
1513-
cachedName = null;
1513+
clearNameCache();
15141514
final String newName = getName();
15151515
if (!StringUtils.equals(oldName, newName)) {
15161516
setLinkInfo(null);
@@ -1540,7 +1540,7 @@ public void forceForcedFileName(String newForced) {
15401540
newForced = this.fixFilename(newForced);
15411541
this.setProperty(PROPERTY_FORCEDFILENAME, newForced);
15421542
}
1543-
cachedName = null;
1543+
clearNameCache();
15441544
final String newName = getName();
15451545
if (!StringUtils.equals(oldName, newName)) {
15461546
setLinkInfo(null);
@@ -1581,7 +1581,7 @@ public void setForcedFileName(String name) {
15811581
this.setProperty(PROPERTY_FORCEDFILENAME, name);
15821582
}
15831583
}
1584-
cachedName = null;
1584+
clearNameCache();
15851585
final String newName = getName();
15861586
if (!StringUtils.equals(oldName, newName)) {
15871587
setLinkInfo(null);
@@ -1591,6 +1591,10 @@ public void setForcedFileName(String name) {
15911591
}
15921592
}
15931593

1594+
private void clearNameCache() {
1595+
cachedName = null;
1596+
}
1597+
15941598
public void setComment(String comment) {
15951599
final boolean changed;
15961600
if (comment == null || comment.length() == 0) {
@@ -1627,12 +1631,12 @@ public void setFinalFileName(String newfinalFileName) {
16271631
if (!StringUtils.isEmpty(newfinalFileName)) {
16281632
newfinalFileName = this.fixFilename(newfinalFileName);
16291633
this.setProperty(PROPERTY_FINALFILENAME, newfinalFileName);
1630-
cachedName = null;// setName calls getName
1634+
clearNameCache();// setName calls getName
16311635
setName(newfinalFileName);
16321636
} else {
16331637
this.removeProperty(PROPERTY_FINALFILENAME);
16341638
}
1635-
cachedName = null;
1639+
clearNameCache();
16361640
final String newName = getName();
16371641
if (!StringUtils.equals(oldName, newName)) {
16381642
setLinkInfo(null);
@@ -1666,7 +1670,7 @@ public void setPluginPatternMatcher(final String pluginPattern) {
16661670
} else {
16671671
this.urlDownload = null;
16681672
}
1669-
cachedName = null;
1673+
clearNameCache();
16701674
if (hasNotificationListener()) {
16711675
notifyChanges(AbstractNodeNotifier.NOTIFY.PROPERTY_CHANGE, new DownloadLinkProperty(this, DownloadLinkProperty.Property.URL_CONTENT, pluginPattern));
16721676
}
@@ -2609,9 +2613,9 @@ public Type getType() {
26092613
}
26102614

26112615
public void setCustomExtension(String extension) {
2612-
String old = getCustomExtension();
2616+
final String old = getCustomExtension();
26132617
setProperty("EXTENSION", extension);
2614-
cachedName = null;
2618+
clearNameCache();
26152619
if (!StringUtils.equals(old, extension) && hasNotificationListener()) {
26162620
notifyChanges(AbstractNodeNotifier.NOTIFY.PROPERTY_CHANGE, new DownloadLinkProperty(this, DownloadLinkProperty.Property.NAME, extension));
26172621
}

svn_trunk/src/jd/plugins/Plugin.java

Lines changed: 40 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -542,20 +542,19 @@ public String getPluginVersionHash() {
542542
* @return Extracted filename.
543543
*/
544544
public static String getFileNameFromConnection(final URLConnectionAdapter urlConnection) {
545-
final Plugin plugin = getCurrentActivePlugin();
546-
return getFileNameFromSource(plugin, FILENAME_SOURCE.CONNECTION, null, null, null, urlConnection);
545+
return getFileNameFromSource(getCurrentActivePlugin(), FILENAME_SOURCE.CONNECTION, null, urlConnection);
547546
}
548547

549-
protected static String getFileNameFromSource(Plugin plugin, FILENAME_SOURCE source, DownloadLink link, String customName, String customExtension, URLConnectionAdapter con) {
548+
protected static String getFileNameFromSource(Plugin plugin, FILENAME_SOURCE source, DownloadLink link, URLConnectionAdapter con, final String... customValues) {
550549
if (plugin != null) {
551-
return plugin.getFileNameFromSource(source, link, customName, customExtension, con);
550+
return plugin.getFileNameFromSource(source, link, con, customValues);
552551
} else {
553-
return source.getFilename(null, link, customName, customExtension, con);
552+
return source.getFilename(null, link, con, customValues);
554553
}
555554
}
556555

557-
protected String getFileNameFromSource(FILENAME_SOURCE source, DownloadLink link, String customName, String customExtension, URLConnectionAdapter con) {
558-
return source.getFilename(this, link, customName, customExtension, con);
556+
protected String getFileNameFromSource(FILENAME_SOURCE source, DownloadLink link, URLConnectionAdapter con, final String... customValues) {
557+
return source.getFilename(this, link, con, customValues);
559558
}
560559

561560
protected String getExtensionFromConnection(URLConnectionAdapter connection) {
@@ -576,6 +575,40 @@ protected String getExtensionFromConnection(URLConnectionAdapter connection) {
576575
return ret;
577576
}
578577

578+
protected String correctOrApplyFileNameExtension(FILENAME_SOURCE source, DownloadLink link, final String fileName, URLConnectionAdapter con, final String... customValues) {
579+
if (fileName == null) {
580+
return null;
581+
}
582+
switch (source) {
583+
case FORCED:
584+
// by default we do not correct forced names
585+
return fileName;
586+
case CONNECTION:
587+
// dummy FILENAME_SOURCE that uses HEADER and URL
588+
return fileName;
589+
case HEADER:
590+
// by default we trust the content-disposition header and do not correct it
591+
return fileName;
592+
default:
593+
return correctOrApplyFileNameExtension(fileName, FILENAME_SOURCE.getCustomExtension(customValues), con);
594+
}
595+
}
596+
597+
protected boolean setFilename(FILENAME_SOURCE source, DownloadLink link, String fileName) {
598+
if (fileName == null) {
599+
return false;
600+
}
601+
switch (source) {
602+
case FORCED:
603+
CrawledLink.setForcedName(link, fileName);
604+
link.setFinalFileName(fileName);
605+
return true;
606+
default:
607+
link.setFinalFileName(fileName);
608+
return true;
609+
}
610+
}
611+
579612
public String correctOrApplyFileNameExtension(final String filenameOrg, String newExtension, URLConnectionAdapter connection) {
580613
final String newExtensionParam = newExtension;
581614
if (connection != null) {

0 commit comments

Comments
 (0)