Skip to content

Commit

Permalink
fix: change rss response encoding from us-ascii to utf8 (#50)
Browse files Browse the repository at this point in the history
  • Loading branch information
guqing authored Dec 16, 2024
1 parent 65b9f23 commit 0b0f3f6
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions app/src/main/java/run/halo/feed/FeedPluginEndpoint.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package run.halo.feed;

import static org.springframework.web.reactive.function.server.RequestPredicates.accept;
import static org.springframework.web.reactive.function.server.RequestPredicates.path;

import java.util.ArrayList;
import lombok.AllArgsConstructor;
import lombok.Builder;
import org.apache.commons.lang3.StringUtils;
Expand All @@ -10,17 +14,17 @@
import org.springframework.security.web.server.util.matcher.ServerWebExchangeMatcher;
import org.springframework.security.web.server.util.matcher.ServerWebExchangeMatchers;
import org.springframework.stereotype.Component;
import org.springframework.web.reactive.function.server.*;
import org.springframework.web.reactive.function.server.HandlerFunction;
import org.springframework.web.reactive.function.server.RequestPredicate;
import org.springframework.web.reactive.function.server.RouterFunction;
import org.springframework.web.reactive.function.server.RouterFunctions;
import org.springframework.web.reactive.function.server.ServerRequest;
import org.springframework.web.reactive.function.server.ServerResponse;
import reactor.core.publisher.Mono;
import run.halo.app.infra.ExternalUrlSupplier;
import run.halo.app.plugin.extensionpoint.ExtensionGetter;
import run.halo.feed.provider.PostRssProvider;

import java.util.ArrayList;

import static org.springframework.web.reactive.function.server.RequestPredicates.accept;
import static org.springframework.web.reactive.function.server.RequestPredicates.path;

@Component
@AllArgsConstructor
public class FeedPluginEndpoint {
Expand Down Expand Up @@ -145,7 +149,8 @@ private String buildPathPattern(String pathPattern, String namespace) {
}

private Mono<ServerResponse> buildResponse(String xml) {
return ServerResponse.ok().contentType(MediaType.TEXT_XML)
// https://www.rssboard.org/rss-validator/docs/warning/EncodingMismatch.html
return ServerResponse.ok().contentType(MediaType.APPLICATION_XML)
.bodyValue(xml);
}
}

0 comments on commit 0b0f3f6

Please sign in to comment.